Merge pull request #4881 from Ccomp5950/botfix

Admin empowerment:  Allowing Admins in IRC to respond to ahelps
This commit is contained in:
Mloc
2014-05-03 11:04:43 +01:00
7 changed files with 134 additions and 2 deletions

View File

@@ -23,4 +23,4 @@
return send_raw("type=keepalive")
var/global/datum/socket_talk/socket_talk
var/global/datum/socket_talk/socket_talk

View File

@@ -152,3 +152,16 @@ datum/admins/proc/notes_gethtml(var/ckey)
log_admin("[key_name(usr)] deleted one of [key]'s notes.")
del info
/proc/show_player_info_irc(var/key as text)
var/dat = " Info on [key]%0D%0A"
var/savefile/info = new("data/player_saves/[copytext(key, 1, 2)]/[key]/info.sav")
var/list/infos
info >> infos
if(!infos)
dat = "No information found on the given key."
else
for(var/datum/player_info/I in infos)
dat += "[I.content]%0D%0Aby [I.author] ([I.rank]) on [I.timestamp]%0D%0A%0D%0A"
return dat

View File

@@ -182,3 +182,28 @@
continue
if(X.key!=key && X.key!=C.key && (X.holder.rights & R_ADMIN) || (X.holder.rights & R_MOD) )
X << "<B><font color='blue'>PM: [key_name(src, X, 0)]-&gt;[key_name(C, X, 0)]:</B> \blue [msg]</font>" //inform X
/client/proc/cmd_admin_irc_pm()
if(prefs.muted & MUTE_ADMINHELP)
src << "<font color='red'>Error: Private-Message: You are unable to use PM-s (muted).</font>"
return
var/msg = input(src,"Message:", "Private message to admins on IRC / 400 character limit") as text|null
sanitize(msg)
if(length(msg) > 400) // TODO: if message length is over 400, divide it up into seperate messages, the message length restriction is based on IRC limitations. Probably easier to do this on the bots ends.
src << "\red Your message was not sent because it was more then 400 characters find your message below for ease of copy/pasting"
src << "\blue [msg]"
return
send2adminirc("PlayerPM from [key_name(src)]: [html_decode(msg)]")
src << "<font color='blue'>IRC PM to-<b>IRC-Admins</b>: [msg]</font>"
log_admin("PM: [key_name(src)]->IRC: [msg]")
for(var/client/X in admins)
if(X == src)
continue
if((X.holder.rights & R_ADMIN) || (X.holder.rights & R_MOD))
X << "<B><font color='blue'>PM: [key_name(src, X, 0)]-&gt;IRC-Admins:</B> \blue [msg]</font>"

View File

@@ -32,6 +32,10 @@
// comment out the line below when debugging locally to enable the options & messages menu
//control_freak = 1
var/received_irc_pm = -99999
var/irc_admin //IRC admin that spoke with them last.
var/mute_irc = 0
////////////////////////////////////
//things that require the database//

View File

@@ -45,6 +45,18 @@
cmd_admin_pm(C,null)
return
if(href_list["irc_msg"])
if(!holder && received_irc_pm < world.time - 6000) //Worse they can do is spam IRC for 10 minutes
usr << "<span class='warning'>You are no longer able to use this, it's been more then 10 minutes since an admin on IRC has responded to you</span>"
return
if(mute_irc)
usr << "<span class='warning'You cannot use this as your client has been muted from sending messages to the admins on IRC</span>"
return
cmd_admin_irc_pm()
return
//Logs all hrefs
if(config && config.log_hrefs && href_logfile)
href_logfile << "<small>[time2text(world.timeofday,"hh:mm")] [src] (usr:[usr])</small> || [hsrc ? "[hsrc] " : ""][href]<br>"

View File

@@ -26,3 +26,4 @@
/hook/startup/proc/ircNotify()
send2mainirc("Server starting up on [config.server? "byond://[config.server]" : "byond://[world.address]:[world.port]"]")
return 1

View File

@@ -66,9 +66,12 @@
// world << "End of Topic() call."
// ..()
var/world_topic_spam_protect_ip = "0.0.0.0"
var/world_topic_spam_protect_time = world.timeofday
/world/Topic(T, addr, master, key)
diary << "TOPIC: \"[T]\", from:[addr], master:[master], key:[key][log_end]"
if (T == "ping")
var/x = 1
for (var/client/C)
@@ -92,6 +95,7 @@
s["ai"] = config.allow_ai
s["host"] = host ? host : null
s["players"] = list()
s["stationtime"] = worldtime2text()
var/n = 0
var/admins = 0
@@ -109,6 +113,79 @@
return list2params(s)
else if(copytext(T,1,9) == "adminmsg")
/*
We got an adminmsg from IRC bot lets split the input then validate the input.
expected output:
1. adminmsg = ckey of person the message is to
2. msg = contents of message, parems2list requires
3. validatationkey = the key the bot has, it should match the gameservers commspassword in it's configuration.
4. sender = the ircnick that send the message.
*/
var/input[] = params2list(T)
if(input["key"] != config.comms_password)
if(world_topic_spam_protect_ip == addr && abs(world_topic_spam_protect_time - world.time) < 50)
spawn(50)
world_topic_spam_protect_time = world.time
return "Bad Key (Throttled)"
world_topic_spam_protect_time = world.time
world_topic_spam_protect_ip = addr
return "Bad Key"
var/client/C
for(var/client/K in clients)
if(K.ckey == input["adminmsg"])
C = K
break
if(!C)
return "No client with that name on server"
var/message = "<font color='red'>IRC-Admin PM from <b><a href='?irc_msg=1'>[C.holder ? "IRC-" + input["sender"] : "Administrator"]</a></b>: [input["msg"]]</font>"
var/amessage = "<font color='blue'>IRC-Admin PM from <a href='?irc_msg=1'>IRC-[input["sender"]]</a> to <b>[key_name(C)]</b> : [input["msg"]]</font>"
C.received_irc_pm = world.time
C.irc_admin = input["sender"]
C << 'sound/effects/adminhelp.ogg'
C << message
for(var/client/A in admins)
if(A != C)
A << amessage
return "Message Successful"
else if(copytext(T,1,6) == "notes")
/*
We got a request for notes from the IRC Bot
expected output:
1. notes = ckey of person the notes lookup is for
2. validationkey = the key the bot has, it should match the gameservers commspassword in it's configuration.
*/
var/input[] = params2list(T)
if(input["key"] != config.comms_password)
if(world_topic_spam_protect_ip == addr && abs(world_topic_spam_protect_time - world.time) < 50)
spawn(50)
world_topic_spam_protect_time = world.time
return "Bad Key (Throttled)"
world_topic_spam_protect_time = world.time
world_topic_spam_protect_ip = addr
return "Bad Key"
return show_player_info_irc(input["notes"])
/world/Reboot(var/reason)
/*spawn(0)