Adds in the Discord Verification system and fixes the bot~

This commit is contained in:
AnonymousHybi
2018-05-20 01:32:12 +01:00
parent f28646dffe
commit e7822eb506
9 changed files with 113 additions and 36 deletions
+8 -1
View File
@@ -124,4 +124,11 @@ CREATE TABLE `vr_player_hours` (
`department` varchar(64) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
`hours` double NOT NULL,
PRIMARY KEY (`ckey`,`department`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `discord2byond` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ckey` varchar(32) NOT NULL,
`userid` int(32) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;
+12 -12
View File
@@ -2,13 +2,13 @@ SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
CREATE SCHEMA IF NOT EXISTS `shawn_chompstation_master` DEFAULT CHARACTER SET latin1 ;
USE `shawn_chompstation_master` ;
CREATE SCHEMA IF NOT EXISTS `tgstation` DEFAULT CHARACTER SET latin1 ;
USE `tgstation` ;
-- -----------------------------------------------------
-- Table `shawn_chompstation_master`.`death`
-- Table `tgstation`.`death`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `shawn_chompstation_master`.`death` (
CREATE TABLE IF NOT EXISTS `tgstation`.`death` (
`id` INT(11) NOT NULL AUTO_INCREMENT ,
`pod` TEXT NOT NULL COMMENT 'Place of death' ,
`coord` TEXT NOT NULL COMMENT 'X, Y, Z POD' ,
@@ -31,9 +31,9 @@ DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `shawn_chompstation_master`.`karma`
-- Table `tgstation`.`karma`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `shawn_chompstation_master`.`karma` (
CREATE TABLE IF NOT EXISTS `tgstation`.`karma` (
`id` INT(11) NOT NULL AUTO_INCREMENT ,
`spendername` TEXT NOT NULL ,
`spenderkey` TEXT NOT NULL ,
@@ -51,9 +51,9 @@ DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `shawn_chompstation_master`.`karmatotals`
-- Table `tgstation`.`karmatotals`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `shawn_chompstation_master`.`karmatotals` (
CREATE TABLE IF NOT EXISTS `tgstation`.`karmatotals` (
`id` INT(11) NOT NULL AUTO_INCREMENT ,
`byondkey` TEXT NOT NULL ,
`karma` INT(11) NOT NULL ,
@@ -64,9 +64,9 @@ DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `shawn_chompstation_master`.`library`
-- Table `tgstation`.`library`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `shawn_chompstation_master`.`library` (
CREATE TABLE IF NOT EXISTS `tgstation`.`library` (
`id` INT(11) NOT NULL AUTO_INCREMENT ,
`author` TEXT NOT NULL ,
`title` TEXT NOT NULL ,
@@ -79,9 +79,9 @@ DEFAULT CHARACTER SET = latin1;
-- -----------------------------------------------------
-- Table `shawn_chompstation_master`.`population`
-- Table `tgstation`.`population`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `shawn_chompstation_master`.`population` (
CREATE TABLE IF NOT EXISTS `tgstation`.`population` (
`id` INT(11) NOT NULL AUTO_INCREMENT ,
`playercount` INT(11) NULL DEFAULT NULL ,
`admincount` INT(11) NULL DEFAULT NULL ,
+35
View File
@@ -0,0 +1,35 @@
// Making this file to allow us to easily understand the location of any modifications to the config file made by Chompers and to try and prevent any conflicts happening in the future.
// Basically a copy pasta from virgo's configuration.dm file but it'll make life easer for us to just toggle on/off.
/datum/configuration
var/discord_restriction = 0
/hook/startup/proc/read_ch_config()
var/list/Lines = file2list("config/config.txt")
for(var/t in Lines)
if(!t) continue
t = trim(t)
if (length(t) == 0)
continue
else if (copytext(t, 1, 2) == "#")
continue
var/pos = findtext(t, " ")
var/name = null
// var/value = null //Commenting out because config doesn't contain any values at the moment. - Jonathan
if (pos)
name = lowertext(copytext(t, 1, pos))
// value = copytext(t, pos + 1) //Commenting out because config doesn't contain any values at the moment. - Jonathan
else
name = lowertext(t)
if (!name)
continue
switch (name)
if ("discord_restriction")
config.discord_restriction = 1
return 1
+1 -1
View File
@@ -3,7 +3,7 @@
hub = "Exadv1.spacestation13"
//hub_password = "SORRYNOPASSWORD"
hub_password = "kMZy3U5jJHSiBQjr"
name = "Space Station 13"
name = "CHOMPstation | Vore RPing Server | Must be in Discord | 24/7 Extended (Test server)"
/* This is for any host that would like their server to appear on the main SS13 hub.
To use it, simply replace the password above, with the password found below, and it should work.
+27
View File
@@ -251,6 +251,8 @@
//Panic bunker code
if (isnum(player_age) && player_age == 0) //first connection
log_adminwarn("[key] has joined for the first time.") //Chompstation edit, notifying admins of a first join <3
message_admins("[key] has joined for the first time.")
if (config.panic_bunker && !holder && !deadmin_holder)
log_adminwarn("Failed Login: [key] - New account attempting to connect during panic bunker")
message_admins("<span class='adminnotice'>Failed Login: [key] - New account attempting to connect during panic bunker</span>")
@@ -258,6 +260,13 @@
qdel(src)
return 0
// Chompstation edit, adds restriction that you can only join with discord account linked to your ckey - Jonathan
if(config.discord_restriction && !IsDiscordLinked(ckey))
to_chat(src,"This server requires you to be linked to the Chompers Discord server in order to connect. Please head to https://chompstation.tk to find out more about our server.")
qdel(src)
return 0
// Chompstation edit end
// VOREStation Edit Start - Department Hours
if(config.time_off)
var/DBQuery/query_hours = dbcon.NewQuery("SELECT department, hours FROM vr_player_hours WHERE ckey = '[sql_ckey]'")
@@ -372,3 +381,21 @@ client/verb/character_setup()
set category = "Preferences"
if(prefs)
prefs.ShowChoices(usr)
// Chompstation Edit, adding a proc to check if their account is linked to discord. - Jonathan
/proc/IsDiscordLinked(ckey)
establish_db_connection()
if(!dbcon.IsConnected())
return null
var/sql_ckey = sql_sanitize_text(ckey)
var/DBQuery/query = dbcon.NewQuery("SELECT * FROM discord2byond WHERE ckey = '[sql_ckey]'")
query.Execute()
if(query.NextRow())
if(ckey in query.item)
return 1
else
return 0
// Chompstation Edit end.
+7 -6
View File
@@ -1,17 +1,18 @@
/proc/send2irc(var/channel, var/msg)
/proc/send2irc(var/msg, var/admin = 0)
if(config.use_irc_bot)
paranoid_sanitize(msg)
ext_python("ircbot_message.py", "[config.comms_password] [config.irc_bot_host] [channel] [msg]")
if(admin)
msg = "ADMIN - [msg]"
// 3rd param is unused in the bot, would spend time to fix this but I'm lazy. - Jon
ext_python("ircbot_message.py", "[config.comms_password] [config.irc_bot_host] null [msg]")
return
/proc/send2mainirc(var/msg)
if(config.main_irc)
send2irc(config.main_irc, msg)
send2irc(msg)
return
/proc/send2adminirc(var/msg)
var/queuedmsg = "ADMIN - [msg]"
send2irc(config.admin_irc, queuedmsg)
send2irc(msg, 1)
return
/hook/startup/proc/ircNotify()
+8 -1
View File
@@ -408,4 +408,11 @@ ENGINE_MAP Supermatter Engine,Edison's Bane
# Applies a limit to the number of assistants and visitors respectively
# LIMIT_INTERNS 6
# LIMIT_VISITORS 6
# LIMIT_VISITORS 6
## Setting to prevent players from joining without having their accounts linked to their discord account.
## WIP system to allow a bot to be a interface to allow basic moderation to both discord and SS13 at the same time.
## A specific bot is required to use this, ask Jonathan123ii on discord about this information.
## Uncomment to enable discord restriction, default off if you leave commented.
# DISCORD_RESTRICTION
+14 -15
View File
@@ -1,31 +1,30 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# Four arguments, password host channel and message.
# EG: "ircbot_message.py hunter2 example.com #adminchannel ADMINHELP, people are killing me!"
import sys,cPickle,socket,HTMLParser
import sys
import socket
def pack():
ht = HTMLParser.HTMLParser()
passwd = sys.argv[1]
ip = sys.argv[3]
try:
data = []
for in_data in sys.argv[4:]: #The rest of the arguments is data
data += {ht.unescape(in_data)}
data = sys.argv[4:]
print(data)
except:
data = "NO DATA SPECIFIED"
dictionary = {"ip":ip,"data":[passwd] + data}
pickled = cPickle.dumps(dictionary)
nudge(pickled)
data = str(data)
data = bytes(data, "ascii")
print(data)
nudge(data)
def nudge(data):
HOST = sys.argv[2]
PORT = 45678
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST,PORT))
s.connect((HOST, PORT))
s.send(data)
s.close()
if __name__ == "__main__" and len(sys.argv) > 1: # If not imported and more than one argument
pack()
if __name__ == "__main__" and len(sys.argv) > 1: # If not imported and more than one argument
pack()
+1
View File
@@ -174,6 +174,7 @@
#include "code\controllers\autotransfer.dm"
#include "code\controllers\communications.dm"
#include "code\controllers\configuration.dm"
#include "code\controllers\configuration_ch.dm"
#include "code\controllers\configuration_vr.dm"
#include "code\controllers\controller.dm"
#include "code\controllers\emergency_shuttle_controller.dm"