This commit is contained in:
randomuser 2021-06-15 17:01:38 +00:00
parent 529b02a5be
commit 8b004b09f9
1 changed files with 34 additions and 13 deletions

47
bot.py
View File

@ -17,7 +17,7 @@ from secrets import PASSWORD
kickees = Nicklist() kickees = Nicklist()
exempt = Nicklist() exempt = Nicklist()
CHANNEL = "#chaos" CHANNEL = "#chaos"
BOTNAME = "rndbotmerp" BOTNAME = "rndbot"
OWNER = "rndusr" OWNER = "rndusr"
TOPIC = "rule one: you are now a duck. ・゜゜・。。・゜゜\\_o< QUACK!" TOPIC = "rule one: you are now a duck. ・゜゜・。。・゜゜\\_o< QUACK!"
SPAMUSER = "" SPAMUSER = ""
@ -30,7 +30,7 @@ class Server(BaseServer):
LOGFILE.write(f"{self.name} < {line.format()}") LOGFILE.write(f"{self.name} < {line.format()}")
if line.command == "001": if line.command == "001":
await self.send(build("PRIVMSG", ["NickServ", "identify " + PASSWORD])) await self.send(build("PRIVMSG", ["NickServ", "identify " + PASSWORD]))
await self.send(build("MODE", [BOTNAME, "+B"])) #await self.send(build("MODE", [BOTNAME, "+B"]))
await self.send(build("JOIN", [CHANNEL])) await self.send(build("JOIN", [CHANNEL]))
if line.command == "474": if line.command == "474":
await self.send(build("PRIVMSG", ["ChanServ", "unban " + CHANNEL + " " + BOTNAME])) await self.send(build("PRIVMSG", ["ChanServ", "unban " + CHANNEL + " " + BOTNAME]))
@ -38,6 +38,9 @@ class Server(BaseServer):
await self.send(build("PRIVMSG", ["ChanServ", "invite " + CHANNEL + " " + BOTNAME])) await self.send(build("PRIVMSG", ["ChanServ", "invite " + CHANNEL + " " + BOTNAME]))
await self.send(build("JOIN", [CHANNEL])) await self.send(build("JOIN", [CHANNEL]))
if line.command == "PRIVMSG" and line.params[0] == CHANNEL: if line.command == "PRIVMSG" and line.params[0] == CHANNEL:
if line.hostmask.nickname == 'tildebot':
if line.params[1] == '・゜゜・。。・゜゜\_o< CHAOS!':
await self.send(build('PRIVMSG', [CHANNEL, ',bef']))
if line.hostmask.nickname == OWNER: if line.hostmask.nickname == OWNER:
if BOTNAME + ": quit" == line.params[1]: if BOTNAME + ": quit" == line.params[1]:
await self.send(build('PART', [CHANNEL, MESSAGES['quit']])) await self.send(build('PART', [CHANNEL, MESSAGES['quit']]))
@ -101,9 +104,11 @@ class Server(BaseServer):
if exempt.read('exempt'): if exempt.read('exempt'):
pass pass
if BOTNAME + ": kickall" in line.params[1]: if BOTNAME + ": kickall" in line.params[1]:
for i in self.channels[CHANNEL].users: for i in self.channels[CHANNEL].users.keys():
if i != OWNER: if i != OWNER and i != BOTNAME:
asyncio.create_task(self.send(build('KICK', [CHANNEL, i, 'nope']))) await self.send(build('KICK', [CHANNEL, i, 'nope']))
if "no u" == line.params[1] and line.hostname.nickname != BOTNAME:
await self.send(build('PRIVMSG', [CHANNEL, 'no u']))
if line.command == "JOIN": if line.command == "JOIN":
if line.hostmask.nickname in kickees: if line.hostmask.nickname in kickees:
@ -120,8 +125,8 @@ class Server(BaseServer):
await self.send(build('MODE', [CHANNEL, '-n'])) await self.send(build('MODE', [CHANNEL, '-n']))
if 'm' in self.channels[CHANNEL].modes: if 'm' in self.channels[CHANNEL].modes:
await self.send(build('MODE', [CHANNEL, '-m'])) await self.send(build('MODE', [CHANNEL, '-m']))
if 's' in self.channels[CHANNEL].modes: # if 's' in self.channels[CHANNEL].modes:
await self.send(build('MODE', [CHANNEL, '-s'])) # await self.send(build('MODE', [CHANNEL, '-s']))
if not 'q' in self.channels[CHANNEL].users[OWNER].modes: if not 'q' in self.channels[CHANNEL].users[OWNER].modes:
await self.send(build('MODE', [CHANNEL, '+q', OWNER])) await self.send(build('MODE', [CHANNEL, '+q', OWNER]))
if 'b' in self.channels[CHANNEL].users[BOTNAME].modes: if 'b' in self.channels[CHANNEL].users[BOTNAME].modes:
@ -131,14 +136,30 @@ class Server(BaseServer):
except KeyError: except KeyError:
pass pass
if line.command == "KICK" and line.params[0] == CHANNEL: if line.command == "KICK" and line.params[0] == CHANNEL:
print(line.params)
if line.params[1] == OWNER: if line.params[1] == OWNER:
await self.send(build('KICK', [CHANNEL, line.hostmask.nickname, MESSAGES['revenge']])) if line.params[2] == 'User has been banned from the channel':
await self.send(build('INVITE', [CHANNEL, line.params[1]])) await self.send(build('PRIVMSG', ['chanserv', \
'akick ' + CHANNEL + ' del ' + OWNER]))
await self.send(build('PRIVMSG', ['chanserv', \
'unban ' + CHANNEL + ' ' + OWNER]))
else:
await self.send(build('KICK', [CHANNEL, line.hostmask.nickname, MESSAGES['revenge']]))
await self.send(build('INVITE', [CHANNEL, line.params[1]]))
if line.params[1] == BOTNAME: if line.params[1] == BOTNAME:
time.sleep(1) if line.params[2] == 'User has been banned from the channel':
await self.send(build('JOIN', [CHANNEL])) await self.send(build('PRIVMSG', ['chanserv', \
time.sleep(0.5) 'akick ' + CHANNEL + ' del ' + BOTNAME]))
await self.send(build('KICK', [CHANNEL, line.hostmask.nickname, MESSAGES['revenge']])) await self.send(build('PRIVMSG', ['chanserv', \
'unban ' + CHANNEL + ' ' + BOTNAME]))
await self.send(build('JOIN', [CHANNEL]))
else:
await self.send(build('PRIVMSG', ['chanserv', \
'akick ' + CHANNEL + ' add ' + line.hostmask.nickname]))
time.sleep(1)
await self.send(build('JOIN', [CHANNEL]))
time.sleep(0.5)
await self.send(build('KICK', [CHANNEL, line.hostmask.nickname, MESSAGES['revenge']]))
if line.command == "TOPIC" and line.params[0] == CHANNEL: if line.command == "TOPIC" and line.params[0] == CHANNEL:
if line.hostmask.nickname != OWNER and \ if line.hostmask.nickname != OWNER and \
line.hostmask.nickname != BOTNAME and \ line.hostmask.nickname != BOTNAME and \