Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]Новая система тикетов для менторов и небольшие новшества для админ тикетов #13350

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions code/__DEFINES/bridge.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@

#define BRIDGE_COLOR_BRIDGE "#adb3f0"

//Mhelp tickets
#define BRIDGE_COLOR_MENTORLOG "#6e713e"

//mention types, can be mappet to specific groups
//if not listed - bot will try to find and slap user
#define BRIDGE_MENTION_HERE "here"
Expand Down
2 changes: 1 addition & 1 deletion code/datums/keybinding/client.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
description = "Ask an mentors for help."

/datum/keybinding/client/mentor_help/down(client/user)
user.get_mentorhelp()
user.mentorhelp()
return TRUE

/datum/keybinding/client/screenshot
Expand Down
5 changes: 3 additions & 2 deletions code/game/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var/global/it_is_a_snow_day = FALSE
data_core = new /obj/effect/datacore()
paiController = new /datum/paiController()
ahelp_tickets = new
mhelp_tickets = new

SetRoundID()
base_commit_sha = GetGitMasterCommit(1)
Expand Down Expand Up @@ -185,7 +186,7 @@ var/global/world_topic_spam_protect_time = world.timeofday
if (packet_data)
if(packet_data["announce"] == "")
return receive_net_announce(packet_data, addr)
if(packet_data["bridge"] == "" && addr == "127.0.0.1") //
if(packet_data["bridge"] == "" && addr == "127.0.0.1") //
bridge2game(packet_data)
return "bridge=1" // no return data in topic, feedback should be send only through bridge

Expand Down Expand Up @@ -662,7 +663,7 @@ var/global/failed_db_connections = 0

packet_data["secret"] = "SECRET"
log_href("WTOPIC: NET ANNOUNCE: \"[list2params(packet_data)]\", from:[sender]")

return proccess_net_announce(packet_data["type"], packet_data, sender)

/world/proc/proccess_net_announce(type, list/data, sender)
Expand Down
33 changes: 29 additions & 4 deletions code/modules/admin/verbs/adminhelp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ var/global/datum/admin_help_tickets/ahelp_tickets
//Tickets statpanel
/datum/admin_help_tickets/proc/stat_entry()
var/num_disconnected = 0
stat("== Admin Tickets ==")
stat("Active Tickets:", astatclick.update("[active_tickets.len]"))
for(var/I in active_tickets)
var/datum/admin_help/AH = I
Expand Down Expand Up @@ -259,6 +260,7 @@ var/global/datum/admin_help_tickets/ahelp_tickets
. += " (<A HREF='?_src_=holder;ahelp=[ref_src];ahelp_action=icissue'>IC</A>)"
. += " (<A HREF='?_src_=holder;ahelp=[ref_src];ahelp_action=close'>CLOSE</A>)"
. += " (<A HREF='?_src_=holder;ahelp=[ref_src];ahelp_action=resolve'>RSLVE</A>)"
. += " (<A HREF='?_src_=holder;ahelp=[ref_src];ahelp_action=handleissue'>HANDLE</A>)"

//private
/datum/admin_help/proc/LinkedReplyName(ref_src)
Expand All @@ -277,7 +279,7 @@ var/global/datum/admin_help_tickets/ahelp_tickets
/datum/admin_help/proc/MessageNoRecipient(msg)
var/ref_src = "\ref[src]"
//Message to be sent to all admins
var/admin_msg = "<span class='adminnotice'><span class='adminhelp'>Ticket [TicketHref("#[id]", ref_src)]</span><b>: [LinkedReplyName(ref_src)] [FullMonty(ref_src)]:</b> <span class='emojify linkify'>[msg]</span></span>"
var/admin_msg = "<span class='adminnotice'><span class='adminhelp'> Admin Ticket [TicketHref("#[id]", ref_src)]</span><b>: [LinkedReplyName(ref_src)] [FullMonty(ref_src)]:</b> <span class='emojify linkify'>[msg]</span></span>"

AddInteraction("<font color='red'>[LinkedReplyName(ref_src)]: [msg]</font>")

Expand Down Expand Up @@ -316,7 +318,7 @@ var/global/datum/admin_help_tickets/ahelp_tickets
log_admin_private(msg)
world.send2bridge(
type = list(BRIDGE_ADMINLOG),
attachment_title = "**Ticket #[id]** reopened by **[key_name(usr)]**",
attachment_title = "**Admin Ticket #[id]** reopened by **[key_name(usr)]**",
attachment_color = BRIDGE_COLOR_ADMINLOG,
)
TicketPanel() //can only be done from here, so refresh it
Expand Down Expand Up @@ -346,7 +348,7 @@ var/global/datum/admin_help_tickets/ahelp_tickets
log_admin_private(msg)
world.send2bridge(
type = list(BRIDGE_ADMINLOG),
attachment_title = "**Ticket #[id]** closed by **[key_name(usr)]**",
attachment_title = "**Admin Ticket #[id]** closed by **[key_name(usr)]**",
attachment_color = BRIDGE_COLOR_ADMINLOG,
)

Expand Down Expand Up @@ -385,7 +387,7 @@ var/global/datum/admin_help_tickets/ahelp_tickets
var/msg = "<span class='warning' size='4'><b>- AdminHelp Rejected! -</b></span><br>" + \
"<span class='warning'><b>Your admin help was rejected.</b> The adminhelp verb has been returned to you so that you may try again.</span><br>" + \
"Please try to be calm, clear, and descriptive in admin helps, do not assume the admin has seen any related events, and clearly state the names of anybody you are reporting."

to_chat_admin_pm(initiator, msg)

var/msg = "Ticket [TicketHref("#[id]")] rejected by [key_name]"
Expand Down Expand Up @@ -422,6 +424,27 @@ var/global/datum/admin_help_tickets/ahelp_tickets
AddInteraction("Marked as IC issue by [key_name]")
Resolve(silent = TRUE)

/datum/admin_help/proc/HandleIssue()
if(state != AHELP_ACTIVE)
return

var/msg = "<font color='red'>Ваш AdminHelp рассматривает: [key_name(usr,FALSE,FALSE)], пожалуйста, будьте терпеливы.</font>"

if(initiator)
to_chat(initiator, msg)

feedback_inc("ahelp_handling")
msg = "Ticket [TicketHref("#[id]")] being handled by **[key_name(usr)]**"
message_admins(msg)
log_admin(msg)
world.send2bridge(
type = list(BRIDGE_ADMINLOG),
attachment_title = "**Тикет #[id]** раcсматривает: **[key_name(usr)]**",
attachment_color = BRIDGE_COLOR_ADMINLOG,

)
AddInteraction("[key_name_admin(usr)] is now handling this ticket.")

//Show the ticket panel
/datum/admin_help/proc/TicketPanel()
var/list/dat = list("<title>Ticket #[id]</title>")
Expand Down Expand Up @@ -498,6 +521,8 @@ var/global/datum/admin_help_tickets/ahelp_tickets
Close()
if("resolve")
Resolve()
if("handleissue")
HandleIssue()
if("reopen")
Reopen()

Expand Down
6 changes: 5 additions & 1 deletion code/modules/client/client_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ var/global/list/blacklisted_builds = list(
tgui_panel = new(src)

global.ahelp_tickets?.ClientLogin(src)
global.mhelp_tickets?.ClientLogin(src)

//Admin Authorisation
holder = admin_datums[ckey]
Expand Down Expand Up @@ -354,7 +355,10 @@ var/global/list/blacklisted_builds = list(
admins -= src
global.ahelp_tickets?.ClientLogout(src)
directory -= ckey
mentors -= src
if(holder)
holder.owner = null
mentors -= src
global.mhelp_tickets?.ClientLogout(src)
clients -= src
QDEL_LIST_ASSOC_VAL(char_render_holders)
LAZYREMOVE(movingmob?.clients_in_contents, src)
Expand Down
183 changes: 174 additions & 9 deletions code/modules/mentor/mentor.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
/var/list/mentor_ckeys = list()//all server mentors list
/var/list/mentors = list() //online mentors
/client
var/datum/mentor/mentorholder = null

var/list/mentor_ckeys = list()
var/global/list/mentors = list()

var/list/mentor_verbs_default = list(
/client/proc/cmd_mentor_ticket_panel
)

/world/proc/load_mentors()
mentor_ckeys.Cut()
Expand Down Expand Up @@ -38,11 +45,169 @@
if(directory[ckey])
mentors += directory[ckey]

/proc/message_mentors(msg, observer_only = FALSE, emphasize = FALSE)
var/style = "admin"
if (emphasize)
style += " emphasized"
msg = "<span class='[style]'><span class='prefix'>MENTOR LOG:</span> <span class='message'>[msg]</span></span>"
/datum/mentor
var/client/owner = null

/datum/mentor/New(ckey)
if(!ckey)
error("Mentor datum created without a ckey argument. Datum has been deleted")
qdel(src)
return
mentor_ckeys[ckey] = src

/datum/mentor/proc/associate(client/C)
if(istype(C))
owner = C
owner.mentorholder = src
owner.add_mentor_verbs()
mentors |= C

/datum/mentor/proc/disassociate()
if(owner)
mentors -= owner
owner.remove_mentor_verbs()
owner.mentorholder = null
mentor_ckeys[owner.ckey] = null
qdel(src)

/client/proc/add_mentor_verbs()
if(mentorholder)
verbs += mentor_verbs_default

/client/proc/remove_mentor_verbs()
if(mentorholder)
verbs -= mentor_verbs_default

/proc/mentor_commands(href, href_list, client/C)
if(href_list["mhelp"])
var/mhelp_ref = href_list["mhelp"]
var/datum/mentor_help/MH = locate(mhelp_ref)
if (MH && istype(MH, /datum/mentor_help))
MH.Action(href_list["mhelp_action"])
else
to_chat(C, "Ticket [mhelp_ref] has been deleted!")

if (href_list["mhelp_tickets"])
mhelp_tickets.BrowseTickets(text2num(href_list["mhelp_tickets"]))


/datum/mentor/Topic(href, href_list)
..()
if (usr.client != src.owner || (!usr.client.mentorholder))
log_admin("[key_name(usr)] tried to illegally use mentor functions.")
message_admins("[usr.key] tried to illegally use mentor functions.")
return

mentor_commands(href, href_list, usr)

/client/proc/cmd_mhelp_reply(whom)
if(prefs.muted & MUTE_PM)
to_chat(src, "<span class='pm warning'>Error: Mentor-PM: You are unable to use admin PM-s (muted).</span>")
return
var/client/C
if(istext(whom))
C = directory[whom]
else if(istype(whom,/client))
C = whom
if(!C)
if(has_mentor_powers(src))
to_chat(src, "<span class='pm warning'>Error: Mentor-PM: Client not found.</span>")
return

var/datum/mentor_help/MH = C.current_mentorhelp

if(MH)
message_mentors("<span class='mentor_channel'>[src] has started replying to [C]'s mentor help.</span>")
var/msg = input(src,"Message:", "Private message to [C]")
if (!msg)
message_mentors("<span class='mentor_channel'>[src] has cancelled their reply to [C]'s mentor help.</span>")
return
cmd_mentor_pm(whom, msg, MH)

/proc/has_mentor_powers(client/C)
return C.holder || C.mentorholder

// This not really a great place to put it, but this verb replaces adminhelp in hotkeys so that people requesting help can select the type they need
// You can still directly adminhelp if necessary, this ONLY replaces the inbuilt hotkeys


/client/proc/cmd_mentor_pm(whom, msg, datum/mentor_help/MH)
set category = "Admin"
set name = "Mentor-PM"
set hidden = 1

if(prefs.muted & MUTE_PM)
to_chat(src, "<span class='pm warning'>Error: Mentor-PM: You are unable to use admin PM-s (muted).</span>")
return

//Not a mentor and no open ticket
if(!has_mentor_powers(src) && !current_mentorhelp)
to_chat(src, "<span class='pm warning'>You can no longer reply to this ticket, please open another one by using the Mentorhelp verb if need be.</span>")
to_chat(src, "<span class='pm notice'>Message: [msg]</span>")
return

var/client/recipient

if(istext(whom))
recipient = directory[whom]

else if(istype(whom,/client))
recipient = whom
//get message text, limit it's length.and clean/escape html
if(!msg)
msg = input(src,"Message:", "Mentor-PM to [whom]")

if(!msg)
return

if(prefs.muted & MUTE_PM)
to_chat(src, "<span class='pm warning'>Error: Mentor-PM: You are unable to use admin PM-s (muted).</span>")
return

if(!recipient)
if(has_mentor_powers(src))
to_chat(src, "<span class='pm warning'>Error:Mentor-PM: Client not found.</span>")
to_chat(src, msg)
else
log_admin("Mentorhelp: [key_name(src)]: [msg]")
current_mentorhelp.MessageNoRecipient(msg)
return

//Has mentor powers but the recipient no longer has an open ticket
if(has_mentor_powers(src) && !recipient.current_mentorhelp)
to_chat(src, "<span class='pm warning'>You can no longer reply to this ticket.</span>")
to_chat(src, "<span class='pm notice'>Message: [msg]</span>")
return

if (src.handle_spam_prevention(msg,MUTE_PM))
return

msg = trim(sanitize(copytext(msg,1,MAX_MESSAGE_LEN)))
if(!msg)
return

var/interaction_message = "<span class='pm notice'>Mentor-PM from-<b>[src]</b> to-<b>[recipient]</b>: [msg]</span>"

if (recipient.current_mentorhelp && !has_mentor_powers(recipient))
recipient.current_mentorhelp.AddInteraction(interaction_message)
if (src.current_mentorhelp && !has_mentor_powers(src))
src.current_mentorhelp.AddInteraction(interaction_message)

// It's a little fucky if they're both mentors, but while admins may need to adminhelp I don't really see any reason a mentor would have to mentorhelp since you can literally just ask any other mentors online
if (has_mentor_powers(recipient) && has_mentor_powers(src))
if (recipient.current_mentorhelp)
recipient.current_mentorhelp.AddInteraction(interaction_message)
if (src.current_mentorhelp)
src.current_mentorhelp.AddInteraction(interaction_message)

to_chat(recipient, "<i><span class='mentor'>Mentor-PM from-<b><a href='?mentorhelp_msg=\ref[src]'>[src]</a></b>: [msg]</span></i>")
to_chat(src, "<i><span class='mentor'>Mentor-PM to-<b>[recipient]</b>: [msg]</span></i>")

log_admin("[key_name(src)]->[key_name(recipient)]: [msg]")

for(var/client/C in mentors)
if(!observer_only || (observer_only && isobserver(C.mob)))
to_chat(C, msg)
if (C != recipient && C != src)
to_chat(C, interaction_message)
for(var/client/C in admins)
if (C != recipient && C != src)
to_chat(C, interaction_message)
Loading
Loading