-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommandParser.py
74 lines (56 loc) · 1.99 KB
/
commandParser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
# modified ircecho.py https://gist.github.com/RobertSzkutak/1326452
import sys
import re
import socket
import string
import sqlite3
from Utilities.StringUtils import *
from Utilities.conf import *
from Utilities.permissionUtils import *
from commands.startnew import *
from commands.listchals import *
from commands.listctfs import *
from commands.create import *
from commands.add import *
from commands.read import *
from commands.deleteNote import *
from commands.notify import *
def cmdParser(user,line,cmd):
if(line[len(line)-1].lower() == "public"):
user = CHAN
del line[len(line)-1]
else:
if(line[2].lower() == CHAN.lower()):
user = CHAN
cmd = cmd.lower()
if(cmd=="help"):
help(user)
elif(cmd=="startnew"):
startnewcmd(line,user)
elif(cmd=="listchal"):
list_chals(user,line)
elif(cmd=="listctf"):
list_CTFs(user,line)
elif(cmd=="create"):
startcreatecmd(user,line)
elif(cmd=="add"):
startaddcmd(user,line)
elif(cmd.startswith("add(")):
startaddcmdparams(user,line)
elif(cmd=="read"):
startreadcmd(user,line)
elif(cmd=="joinfail"):#pm to bot if it connects but doesnt join channel
join_chan_if_it_fails()
elif(cmd=="deletenote"):#pm to bot if it connects but doesnt join channel
startDeleteNoteCmd(user,line)
elif(cmd=="notify"):
startnotifycmd(user,getUser(line),line)
def help(user=CHAN):
printUser(".help [public], .startnew <CTF> , .listchal <CTF> , .listctf , .create <CTF> <chalname> , .add <CTF> <chalname> <note>, or .add(CTF,Challenge,Note) .read [-v] <CTF> <chalname> , .notify ON/OFF",user)
printUser("Do not use whitespace in CTF name(you can use it in challenge name)", user)
printUser("Prefix your note with \"note:\" (without quotes)", user)
print("HELP\n")
def join_chan_if_it_fails():
#patch because it doesnt join each time
printBytes(bytes("JOIN %s\r\n" % CHAN,"UTF-8"))