forked from devzspy/GameSpy-Openspy-Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChatMonitor.py
137 lines (113 loc) · 4.86 KB
/
ChatMonitor.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/python
import sys
import socket
import string
import re
import codecs
import time
import thread
from time import sleep
import datetime
reload(sys)
sys.setdefaultencoding("utf-8")
# -*- coding: utf8 -*-
NETWORK = 'peerchat.gamespy.com'
PORT = 6667
NICK = 'ChatMonitor-gs'
ALT_NICK = 'ChatMonitor-gs'
CHAN = ['#gsp!subhome', '#gsp!gsarcadetour', '#gsp!chatmain', '#gsp!servers', '#gsp!arena', '#gsp!livewire', '#GSP!webgames',
'#gsp!fileplanet']
IDENTD = 'XaaaaaaaaX|10008'
REALNAME = 'ChatMonitor'
CONNECTED = False
OPER_NAME = "ChatMonitor"
OPER_EMAIL = 'chatmonitor@gamespy.com'
OPER_PASSWORD = 'Password'
s = socket.socket()
'''
Sub Functions
'''
def operArcade(name, email, password):
try:
s.send("OPER %s %s %s\r\n" % (name, email, password))
except:
return
def loadStartChannels(CHANNELS_LIST):
for channel in CHANNELS_LIST:
try:
s.send("JOIN %s\r\n" % channel)
#Uncomment to set profile picture and subscriber status (can't remember if ChatMonitor had "subscriber" oh well)
#s.send("setckey %s %s :\\b_look\\portrait,icon\r\n" % (channel, NICK))
#s.send("setckey %s %s :\\b_reg60\\1\r\n" % (channel, NICK))
except:
continue
##################################################################################
'''
Main Function
'''
def main(NETWORK, NICK, CHAN, PORT):
flag = True
readbuffer = ""
global CONNECTED
banned_words = ['nigger', 'spic', 'chink', 'faggot', 'crack', 'gameranger', 'voobly', 'xfire', 'gook', 'warez']
s.connect((NETWORK, PORT))
s.send("NICK %s\r\n" % NICK)
s.send("USER %s %s bla :%s\r\n" % (IDENTD, NETWORK, REALNAME))
while (flag):
readbuffer = readbuffer + s.recv(4096)
#Uncomment for debugging
# print readbuffer
temp = string.split(readbuffer, "\n")
readbuffer = temp.pop()
for line in temp:
line = string.rstrip(line)
line = string.split(line)
line = [re.sub("^:", "", rep) for rep in line]
line = [x.decode('utf-8') for x in line]
#Uncomment for debugging
#print line
if ("PING" not in line and CONNECTED == True and "PRIVMSG" in line):
user = line[0].split("!", 1)
user = user[0]
channel = line[2]
msg = line[3:]
print "[IN][%s][%s]%s" % (user, channel, ' '.join(msg))
try:
if (line[0] == "PING"):
print "[IN]PING %s" %line[1]
s.send("PONG %s\r\n" % line[1])
print "[OUT]PONG %s" % line[1]
'''
On connect
'''
if ("372" in line and "Welcome" in line and "GameSpy" in line):
CONNECTED = True
operArcade(OPER_NAME, OPER_EMAIL, OPER_PASSWORD)
sleep(5)
loadStartChannels(CHAN)
if("PRIVMSG" in line and line[2] == NICK):
user = line[0].split("!", 1)
user = user[0]
s.send("PRIVMSG %s :I'm a bot. I'm here to enforce chat standards. You can read them here: http://www.gamespyarcade.com/support/chatrules.shtml" % user)
print "[OUT][%s]I'm a bot. I'm here to enforce chat standards. You can read them here: http://www.gamespyarcade.com/support/chatrules.shtml" % user
if("ATM" in line and line[2] == NICK and "?IMP" in line and "INFO" in line):
user = line[0].split("!", 1)
user = user[0]
s.send("NOTICE %s :Client Info: build=[5228] ip=[54.191.86.65] email=[chatmonitor@gamespy.com] pid=[10008] reg=[1]\r\n" % user)
print "[OUT][%s]Client Info: build=[5228] ip=[54.191.86.65] email=[chatmonitor@gamespy.com] pid=[10008] reg=[1]" % user
if any(word in [x.lower() for x in line] for word in banned_words):
channel = line[2]
userHostMask = line[0].split("@",1)
userHostMask = userHostMask[1]
for bword in banned_words:
if bword in [x.lower() for x in line]:
new_line = [x.lower() for x in line]
word = new_line.index(bword)
s.send("ATM %s ATM :CHDEL %s\r\n" % (channel, line[word]))
#Uncomment if you wish to "Gag" a user from talking for 24 hours.
#s.send("setusermode X \hostmask\%s\modeflags\g\expiressec\86400\comment\User used offensive word - Gag period 1 day" % userHostMask)
except s.timeout:
CONNECTED = False
main(NETWORK, NICK, CHAN, PORT)
continue
main(NETWORK, NICK, CHAN, PORT)