SShttp + SSdiscord | ASYNCHRONOUS STUFF IN BYOND! (#14762)

* SShttp + SSdiscord | ASYNCHRONOUS STUFF IN BYOND!

* Cleanup

* HTTP Callback example

* Fixes rust instability

* More refactors

* This works

* The sanitizer (Now worth £3000)

* New configs + other stuff

* Lets give this a shot

* Farie changes

* Mentor support

* Farie fixes
This commit is contained in:
AffectedArc07
2020-11-07 16:57:47 +00:00
committed by GitHub
parent dbe4e00f43
commit 56752b0e78
29 changed files with 652 additions and 213 deletions
+5 -5
View File
@@ -12,7 +12,7 @@
var/bantype_pass = 0
var/bantype_str
var/maxadminbancheck //Used to limit the number of active bans of a certein type that each admin can give. Used to protect against abuse or mutiny.
var/announceinirc //When set, it announces the ban in irc. Intended to be a way to raise an alarm, so to speak.
var/announce_in_discord = FALSE //When set, it announces the ban in irc. Intended to be a way to raise an alarm, so to speak.
var/blockselfban //Used to prevent the banning of yourself.
var/kickbannedckey //Defines whether this proc should kick the banned person, if they are connected (if banned_mob is defined).
//some ban types kick players after this proc passes (tempban, permaban), but some are specific to db_ban, so
@@ -46,14 +46,14 @@
duration = -1
bantype_pass = 1
maxadminbancheck = 1
announceinirc = 1
announce_in_discord = TRUE
blockselfban = 1
kickbannedckey = 1
if(BANTYPE_ADMIN_TEMP)
bantype_str = "ADMIN_TEMPBAN"
bantype_pass = 1
maxadminbancheck = 1
announceinirc = 1
announce_in_discord = TRUE
blockselfban = 1
kickbannedckey = 1
@@ -141,8 +141,8 @@
to_chat(usr, "<span class='notice'>Ban saved to database.</span>")
message_admins("[key_name_admin(usr)] has added a [bantype_str] for [ckey] [(job)?"([job])":""] [(duration > 0)?"([duration] minutes)":""] with the reason: \"[reason]\" to the ban database.",1)
if(announceinirc)
send2irc("BAN ALERT","[a_ckey] applied a [bantype_str] on [ckey]")
if(announce_in_discord)
SSdiscord.send2discord_simple(DISCORD_WEBHOOK_ADMIN, "**BAN ALERT** [a_ckey] applied a [bantype_str] on [ckey]")
if(kickbannedckey)
if(banned_mob && banned_mob.client && banned_mob.client.ckey == banckey)
+1
View File
@@ -82,6 +82,7 @@
if(!SSipintel.enabled)
return
// Do not refactor this to use SShttp, because that requires the subsystem to be firing for requests to be made, and this will be triggered before the MC has finished loading
var/list/http[] = world.Export("http://[config.ipintel_domain]/check.php?ip=[ip]&contact=[config.ipintel_email]&format=json&flags=b")
if(http)
+23 -55
View File
@@ -34,62 +34,30 @@ GLOBAL_LIST_INIT(adminhelp_ignored_words, list("unknown","the","a","an","of","mo
else
SStickets.newHelpRequest(src, msg)
//See how many staff are on
var/admin_number_afk = 0
var/list/mentorholders = list()
var/list/modholders = list()
var/list/adminholders = list()
for(var/client/X in GLOB.admins)
if(check_rights(R_ADMIN, 0, X.mob))
if(X.is_afk())
admin_number_afk++
adminholders += X
continue
if(check_rights(R_MOD, 0, X.mob))
modholders += X
continue
if(check_rights(R_MENTOR, 0, X.mob))
mentorholders += X
continue
//show it to the person adminhelping too
to_chat(src, "<span class='boldnotice'>[selected_type]</b>: [msg]</span>")
var/admin_number_present = adminholders.len - admin_number_afk
log_admin("[selected_type]: [key_name(src)]: [msg] - heard by [admin_number_present] non-AFK admins.")
if(admin_number_present <= 0)
if(!admin_number_afk)
send2adminirc("[selected_type] from [key_name(src)]: [msg] - !!No admins online!!")
else
send2adminirc("[selected_type] from [key_name(src)]: [msg] - !!All admins AFK ([admin_number_afk])!!")
else
send2adminirc("[selected_type] from [key_name(src)]: [msg]")
feedback_add_details("admin_verb","AH") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
return
/proc/send2irc_adminless_only(source, msg, requiredflags = R_BAN)
var/admin_number_total = 0 //Total number of admins
var/admin_number_afk = 0 //Holds the number of admins who are afk
var/admin_number_ignored = 0 //Holds the number of admins without +BAN (so admins who are not really admins)
var/admin_number_decrease = 0 //Holds the number of admins with are afk, ignored or both
for(var/client/X in GLOB.admins)
admin_number_total++
var/invalid = 0
if(requiredflags != 0 && !check_rights_for(X, requiredflags))
admin_number_ignored++
invalid = 1
if(X.is_afk())
admin_number_afk++
invalid = 1
if(X.holder.fakekey)
admin_number_ignored++
invalid = 1
if(invalid)
admin_number_decrease++
var/admin_number_present = admin_number_total - admin_number_decrease //Number of admins who are neither afk nor invalid
if(admin_number_present <= 0)
if(!admin_number_afk && !admin_number_ignored)
send2irc(source, "[msg] - No admins online")
else
send2irc(source, "[msg] - All admins AFK ([admin_number_afk]/[admin_number_total]) or skipped ([admin_number_ignored]/[admin_number_total])")
return admin_number_present
switch(selected_type)
if("Adminhelp")
//See how many staff are on
var/list/admincount = staff_countup(R_BAN)
var/active_admins = admincount[1]
log_admin("[selected_type]: [key_name(src)]: [msg] - heard by [active_admins] non-AFK admins.")
SSdiscord.send2discord_simple_noadmins("[selected_type] from [key_name(src)]: [msg]", check_send_always = TRUE)
if("Mentorhelp")
var/alerttext
var/list/mentorcount = staff_countup(R_MENTOR)
var/active_mentors = mentorcount[1]
var/inactive_mentors = mentorcount[3]
if(active_mentors <= 0)
if(inactive_mentors > 0)
alerttext = " | **ALL MENTORS AFK**"
else
alerttext = " | **NO MENTORS ONLINE**"
log_admin("[selected_type]: [key_name(src)]: [msg] - heard by [active_mentors] non-AFK mentors.")
SSdiscord.send2discord_simple(DISCORD_WEBHOOK_MENTOR, "[key_name(src)]: [msg][alerttext]")
+16 -10
View File
@@ -211,34 +211,40 @@
i.addResponse(src, msg)
return
/client/proc/cmd_admin_irc_pm()
/client/proc/cmd_admin_discord_pm()
if(prefs.muted & MUTE_ADMINHELP)
to_chat(src, "<span class='danger'>Error: Private-Message: You are unable to use PM-s (muted).</span>")
to_chat(src, "<span class='danger'>Error: Private-Message: You are unable to use PMs (muted).</span>")
return
var/msg = clean_input("Message:", "Private message to admins on IRC / 400 character limit", , src)
if(last_discord_pm_time > world.time)
to_chat(usr, "<span class='warning'>Please wait [(last_discord_pm_time - world.time)/10] seconds, or for a reply, before sending another PM to Discord.</span>")
return
// We only allow PMs once every 10 seconds, othewrise the channel can get spammed very quickly
last_discord_pm_time = world.time + 10 SECONDS
var/msg = clean_input("Message:", "Private message to admins on Discord / 400 character limit", , src)
if(!msg)
return
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.
if(length(msg) > 400) // Dont want them super spamming
to_chat(src, "<span class='warning'>Your message was not sent because it was more then 400 characters find your message below for ease of copy/pasting</span>")
to_chat(src, "<span class='notice'>[msg]</span>")
return
send2adminirc("PlayerPM from [key_name(src)]: [html_decode(msg)]")
SSdiscord.send2discord_simple(DISCORD_WEBHOOK_ADMIN, "PM from [key_name(src)]: [html_decode(msg)]")
to_chat(src, "<span class='pmsend'>IRC PM to-<b>IRC-Admins</b>: [msg]</span>")
to_chat(src, "<span class='pmsend'>PM to-<b>Discord Admins</b>: [msg]</span>")
log_admin("PM: [key_name(src)]->IRC: [msg]")
log_admin("PM: [key_name(src)]->Discord: [msg]")
for(var/client/X in GLOB.admins)
if(X == src)
continue
if(check_rights(R_ADMIN|R_MOD|R_MENTOR, 0, X.mob))
to_chat(X, "<B><span class='pmsend'>PM: [key_name(src, TRUE, 0)]-&gt;IRC-Admins:</B> <span class='notice'>[msg]</span></span>")
if(check_rights(R_ADMIN, 0, X.mob))
to_chat(X, "<span class='pmsend'><b>PM: [key_name_admin(src)]-&gt;Discord Admins:</b> <span class='notice'>[msg]</span></span>")
/client/verb/open_pms_ui()
set name = "My PMs"