-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmail.py
103 lines (80 loc) · 2.39 KB
/
mail.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
from volapi import Room
import time
# Options
name = "MailBot"
room = "PHS-Nb"
password = "password"
blacklist = [
"anon3000"
]
# Don't touch the code below.
myoc = Room(room, name)
try:
myoc.user.login(password)
except Exception:
print("Failed to login!")
'''
Mail syntax:
'dongmaster' : {
'reciever' : "dongmaster",
'sender' : "myon",
'message' : "ur a faget"
}
'''
messages = {
}
is_staff = False
should_send = True
can_split = True
blacklisted_user = False
def onmessage(msg):
global messages
global is_staff
global should_send
global can_split
global blacklisted_user
if msg.msg == "!mbkill" and msg.admin == True and msg.nick.casefold() == "dongmaster".casefold():
myoc.post_chat("Goodbye, cruel world!")
myoc.listen(onmessage = False)
myoc.clear()
myoc.close()
if msg.nick.casefold() != name.casefold():
try:
splitmsg = msg.msg.split(' ', 2)
except Exception:
print("Could not split message, probably too short.")
can_split = False
#if splitmsg[0] == "!w" or splitmsg[0] == "!whisper" or splitmsg[0] == "!m" or splitmsg[0] == "!mail":
if splitmsg[0] in ("!w", "!whisper", "!m", "!mail") and len(splitmsg) >= 3 and can_split == True:
if splitmsg[1].lower() in blacklist:
blacklisted_user = True
myoc.post_chat("That is a blacklisted user. Sending mail to that person is not allowed.")
if blacklisted_user == False:
print("it's werking")
reciever = splitmsg[1]
sender = msg.nick
message = splitmsg[2]
messages[reciever.casefold()] = {
'reciever' : reciever,
'sender' : sender,
'message' : message
}
print("got message \n reciever: " + reciever + "\n sender: " + sender + "\n message: " + message)
myoc.post_chat("Added to mail pool.")
if msg.nick.casefold() == sender.casefold():
should_send = False
try:
if should_send == True:
dict = messages[msg.nick.casefold()]
dict_reciever = dict['reciever']
dict_sender = dict['sender']
dict_message = dict['message']
#myoc.post_chat(str(dict_reciever) + ", " + str(dict_sender) + " sent you a message: " + str(dict_message))
myoc.post_chat("From: " + str(dict_sender) + "\nTo: " + dict_reciever + " \n" + str(dict_message))
del messages[msg.nick.casefold()]
except Exception:
print("Failed to deliver mail.")
should_send = True
can_split = True
blacklisted_user = False
myoc.listen(onmessage = onmessage)