mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 06:00:16 +01:00
NTRC (PDA chatrooms) bugfixes
Removed operator, revamped structure, fixed a lot of bugs Adds myself to admins.txt
This commit is contained in:
@@ -635,40 +635,26 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
||||
var/t = stripped_input(U, "Please enter channel", name, (chat_channel)) as text
|
||||
|
||||
if(t)
|
||||
ntrclog[chat_channel] = "<hr>" + ntrclog[chat_channel]
|
||||
var/datum/chatroom/C = chatchannels[chat_channel]
|
||||
if(!findtext(t,"#",1,2))
|
||||
t = "#" + t
|
||||
chat_channel = t
|
||||
C.parse_msg(src, nick, "/join [chat_channel]")
|
||||
var/ret = C.parse_msg(src, nick, "/join [t]")
|
||||
if((ret in chatchannels) && (ret != chat_channel))
|
||||
ntrclog[chat_channel] = "<hr>" + ntrclog[chat_channel]
|
||||
chat_channel = ret
|
||||
|
||||
if("NTRC Message")
|
||||
var/t = msg_input(U) as text
|
||||
var/datum/chatroom/C = chatchannels[chat_channel]
|
||||
if(C)
|
||||
var/lt = text2list(t, " ")
|
||||
if(lt[1] == "/join")
|
||||
if(!findtext(lt[2],"#",1,2))
|
||||
lt[2] = "#" + lt[2]
|
||||
var/ret = C.parse_msg(src,nick,t)
|
||||
if(findtextEx(ret,"ERR_",1,5))
|
||||
if(findtextEx(ret,"BAD_",1,5))
|
||||
ntrclog[chat_channel] = "[ret]<br>" + ntrclog[chat_channel]
|
||||
else
|
||||
if(ret == 0)
|
||||
ntrclog[chat_channel] = "Failure<br>" + ntrclog[chat_channel]
|
||||
else
|
||||
if(lt[1] == "/join")
|
||||
chat_channel = lt[2]
|
||||
else if(ret in chatchannels)
|
||||
chat_channel = ret
|
||||
|
||||
if("NTRC Help")
|
||||
var/helptext = "<b>NTRC reference:</b><br><br>"
|
||||
helptext += "<i>General commands</i><br>"
|
||||
helptext += "/join #channel<br>/part<br>/log amountoflines<br>/who<br>/topic<br>/register<br><br>"
|
||||
helptext += "<i>Moderation commands</i><br>"
|
||||
helptext += "/ban targetnick<br>/unban targetnick<br>/kick targetnick<br>/mute targetnick<br><br>"
|
||||
helptext += "<i>Management commands</i><br>"
|
||||
helptext += "/topic topictext<br>/op targetnick<br>/deop targetnick<br>/delchannel"
|
||||
usr << browse(helptext, "window=ntrchelp;size=400x444;border=1;can_resize=1;can_close=1;can_minimize=0")
|
||||
var/helptext = "<b>NTRC Commands:</b><br><br>"
|
||||
helptext += "/join #channel<br>/register<br>/log amountoflines<br><br>"
|
||||
usr << browse(helptext, "window=ntrchelp;size=200x200;border=1;can_resize=1;can_close=1;can_minimize=1")
|
||||
|
||||
|
||||
|
||||
@@ -1161,7 +1147,7 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
||||
ntrclog[C] = msg + ntrclog[C]
|
||||
else
|
||||
ntrclog[channel] = msg + ntrclog[channel]
|
||||
if (!silent)
|
||||
if (findtext(message, nick) && !silent)
|
||||
loc.audible_message("\icon[src] *[ttone]*", null, 3)
|
||||
|
||||
/proc/get_viewable_pdas()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var/datum/chatroom/default_ntrc_chatroom = new("")
|
||||
var/datum/chatroom/default_ntrc_chatroom = new()
|
||||
var/list/chatchannels = list(default_ntrc_chatroom.name = default_ntrc_chatroom)
|
||||
|
||||
//procs that can be used directly:
|
||||
@@ -6,13 +6,9 @@ var/list/chatchannels = list(default_ntrc_chatroom.name = default_ntrc_chatroom)
|
||||
|
||||
/datum/chatroom
|
||||
var/name = "#ss13"
|
||||
var/topic = "Welcome to the best NTRC channel in this sector of the galaxy!" // topic message for the chatroom
|
||||
var/list/operators = list() // chat operators
|
||||
var/list/logs = list() // chat logs
|
||||
var/list/muted = list() // muted users
|
||||
var/list/banned = list() // banned users
|
||||
var/list/auth = list() // authenticated clients
|
||||
var/list/users = list() // current users
|
||||
var/list/authed = list() //authenticated users
|
||||
var/datum/events/events = new ()
|
||||
var/list/datum/event/evlist = list()
|
||||
|
||||
@@ -22,20 +18,25 @@ var/list/chatchannels = list(default_ntrc_chatroom.name = default_ntrc_chatroom)
|
||||
/datum/chatroom/proc/parse_msg(client,nick,message)
|
||||
var/obj/machinery/message_server/MS = check_server(client)
|
||||
if(!MS)
|
||||
return "ERR_TCOM"
|
||||
return "BAD_TCOM"
|
||||
|
||||
if(!nick || length(nick) > 8)
|
||||
return "ERR_NICK"
|
||||
if(!get_auth(client,nick) || !nick || length(nick) > 8)
|
||||
return "BAD_NICK"
|
||||
|
||||
MS.send_chat_message(nick,name,message)
|
||||
|
||||
if(findtext(message,"/",1,2))
|
||||
return handle_command(client,nick,copytext(message,2))
|
||||
var/list/cmd=text2list(message, " ")
|
||||
switch(cmd[1])
|
||||
if("/register")
|
||||
return register_auth(client,nick)
|
||||
if("/join")
|
||||
if(cmd[2]) return channel_join(client,nick,cmd[2])
|
||||
if("/log")
|
||||
if(cmd[2]) return get_log(client,nick,cmd[2])
|
||||
|
||||
else
|
||||
return send_message(client,nick,message)
|
||||
return send_message(client,nick,message)
|
||||
|
||||
//the following are for internal use only
|
||||
//the following are helper procs, FOR INTERNAL USE ONLY
|
||||
|
||||
/datum/chatroom/proc/check_server(client)
|
||||
var/atom/C = client
|
||||
@@ -45,168 +46,51 @@ var/list/chatchannels = list(default_ntrc_chatroom.name = default_ntrc_chatroom)
|
||||
var/turf/T = get_turf(MS)
|
||||
if(MS.active && (T.z == CT.z))
|
||||
return MS
|
||||
return 0
|
||||
|
||||
/datum/chatroom/proc/handle_command(client,nick,command) //command parser
|
||||
var/list/cmd=text2list(command, " ")
|
||||
|
||||
if(!get_auth(client,nick))
|
||||
return "ERR_AUTH"
|
||||
|
||||
switch(cmd[1]) //argument-less commmands
|
||||
if("topic")
|
||||
if(cmd.len == 1)
|
||||
return get_topic(client)
|
||||
else
|
||||
return set_topic(client,nick,cmd[2])
|
||||
if("part")
|
||||
return channel_part(client,nick)
|
||||
if("delchannel")
|
||||
return delete_channel(client,nick)
|
||||
if("who")
|
||||
return get_who(client, nick)
|
||||
if("register")
|
||||
return register_auth(client,nick)
|
||||
|
||||
if(cmd.len == 1)
|
||||
return "ERR_ARGS"
|
||||
|
||||
switch(cmd[1]) //commands with 1 arg
|
||||
if("join")
|
||||
return channel_join(client,nick,cmd[2])
|
||||
if("log")
|
||||
return get_log(client,nick,cmd[2])
|
||||
if("op")
|
||||
return make_op(client,nick,cmd[2])
|
||||
if("deop")
|
||||
return deop(client,nick,cmd[2])
|
||||
if("ban")
|
||||
return ban(client,nick,cmd[2])
|
||||
if("unban")
|
||||
return unban(client,nick,cmd[2])
|
||||
if("kick")
|
||||
return kick(client,nick,cmd[2])
|
||||
if("mute")
|
||||
return mute_nick(client,nick,cmd[2])
|
||||
|
||||
return "ERR_WCMD"
|
||||
return null
|
||||
|
||||
/datum/chatroom/proc/send_message(client,nick,message) //standard message
|
||||
if(nick in muted)
|
||||
return "ERR_MUTE"
|
||||
if(!message)
|
||||
return "ERR_BLNK"
|
||||
logs += "[strip_html_properly(nick)]> [strip_html_properly(message)]"
|
||||
return 0
|
||||
logs.Insert(1,"[strip_html_properly(nick)]> [strip_html_properly(message)]")
|
||||
log_chat("[usr]/([usr.ckey]) as [nick] sent to [name]: [message]")
|
||||
events.fireEvent("msg_chat",name,nick,message)
|
||||
return 1
|
||||
|
||||
/datum/chatroom/proc/get_auth(client,nick) //check auth
|
||||
if((!(nick in auth)) || (auth[nick] == client))
|
||||
if((!(nick in authed)) || (auth[client] == nick))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
//chat commands go here
|
||||
//chat commands go here, FOR INTERNAL USE ONLY
|
||||
/datum/chatroom/proc/register_auth(client,nick) //register
|
||||
if(!get_auth(client,nick))
|
||||
return 0
|
||||
auth[nick] = client
|
||||
return "BAD_REGS"
|
||||
auth[client] = nick
|
||||
authed += nick
|
||||
return 1
|
||||
|
||||
/datum/chatroom/proc/delete_channel(client,nick) //delchannel
|
||||
if(nick in operators)
|
||||
for(var/event in events.events)
|
||||
events.clearEvent("msg_chat",event)
|
||||
qdel(src)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/datum/chatroom/proc/channel_join(client,nick,channel) //join
|
||||
if(!findtext(channel,"#",1,2))
|
||||
channel = "#" + channel
|
||||
if(channel == name)
|
||||
if((nick in banned) || (nick in users))
|
||||
return 0
|
||||
users += nick
|
||||
get_topic(client,nick)
|
||||
evlist[nick] = events.addEvent("msg_chat",client,"msg_chat")
|
||||
return 1
|
||||
else
|
||||
if(channel == name) //join this channel
|
||||
if(!(client in evlist))
|
||||
evlist[client] = events.addEvent("msg_chat",client,"msg_chat")
|
||||
return name
|
||||
|
||||
else //leave this channel, join another one
|
||||
if(client in evlist)
|
||||
events.clearEvent("msg_chat",evlist[client])
|
||||
evlist -= client
|
||||
if(!(channel in chatchannels))
|
||||
var/ret = new_channel(client,nick,channel)
|
||||
if(!ret)
|
||||
return 0
|
||||
channel_part(client,nick)
|
||||
var/datum/chatroom/NC = new /datum/chatroom()
|
||||
NC.name = channel
|
||||
chatchannels[channel] = NC
|
||||
var/datum/chatroom/C = chatchannels[channel]
|
||||
return C.parse_msg(client,nick,"/join [channel]")
|
||||
|
||||
/datum/chatroom/proc/channel_part(client,nick) //part
|
||||
users -= nick
|
||||
events.clearEvent("msg_chat",evlist[nick])
|
||||
return 1
|
||||
|
||||
/datum/chatroom/proc/make_op(client,nick,target) //op
|
||||
if(nick in operators)
|
||||
operators += target
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/datum/chatroom/proc/deop(client,nick,target) //deop
|
||||
if(nick in operators)
|
||||
operators -= target
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/datum/chatroom/proc/ban(client,nick,target) //ban
|
||||
if(nick in operators)
|
||||
banned += target
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/datum/chatroom/proc/unban(client,nick,target) //unban
|
||||
if(nick in operators)
|
||||
banned -= target
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/datum/chatroom/proc/kick(client,nick,target) //kick
|
||||
if(nick in operators)
|
||||
channel_part(null,nick)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/datum/chatroom/proc/set_topic(client,nick,newtopic) //topic
|
||||
if(nick in operators)
|
||||
topic = strip_html_properly(newtopic)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/datum/chatroom/proc/get_topic(client,nick) //topic
|
||||
call(client,"msg_chat")(name,"NTbot","TOPIC: [topic]")
|
||||
return 1
|
||||
|
||||
/datum/chatroom/proc/get_who(client,nick) //who
|
||||
for(var/user in users)
|
||||
call(client,"msg_chat")(name,"NTbot","WHO: [user]")
|
||||
return 1
|
||||
|
||||
/datum/chatroom/proc/get_log(client,nick,lines) //log
|
||||
lines = text2num(lines)
|
||||
lines = min(lines, logs.len)
|
||||
for(var/i=0;i<lines;i++)
|
||||
var/mylog = logs[logs.len-i]
|
||||
call(client,"msg_chat")(name,"NTbot","LOG[i]: [mylog]")
|
||||
return 1
|
||||
|
||||
/datum/chatroom/proc/mute_nick(client,nick,target) //mute
|
||||
if(nick in operators)
|
||||
muted += target
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/datum/chatroom/proc/new_channel(client,nick,target) //called by join
|
||||
if(target in chatchannels)
|
||||
return 0
|
||||
chatchannels[target] = new /datum/chatroom()
|
||||
var/datum/chatroom/C = chatchannels[target]
|
||||
C.name = target
|
||||
C.operators += nick
|
||||
call(client,"msg_chat")(name,"NTbot","LOG[i]: [logs[(logs.len)-i]]")
|
||||
return 1
|
||||
|
||||
+2
-1
@@ -67,4 +67,5 @@ cookingboy3 = Game Master
|
||||
limeliz = Game Master
|
||||
steelpoint = Game Master
|
||||
phil235 = Game Master
|
||||
xxnoob = Game Master
|
||||
xxnoob = Game Master
|
||||
tkdrg = Game Master
|
||||
|
||||
Reference in New Issue
Block a user