2020-04-05 15:39:50 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
2020-04-05 22:25:19 +00:00
|
|
|
import pydle, asyncio, sys, os
|
2020-04-05 15:39:50 +00:00
|
|
|
|
|
|
|
class Oven(pydle.Client):
|
|
|
|
async def on_connect(self):
|
|
|
|
print('Connected!')
|
|
|
|
|
2020-04-05 22:25:19 +00:00
|
|
|
self.modules = {}
|
|
|
|
self.cmd = {}
|
|
|
|
self.raw = {}
|
|
|
|
self.help = {}
|
|
|
|
|
|
|
|
print('loading modules...')
|
|
|
|
await self.loadMods()
|
2020-04-06 00:21:10 +00:00
|
|
|
print('joining channels')
|
|
|
|
for i in self.chansjoin:
|
|
|
|
await self.join(i)
|
2020-04-05 22:25:19 +00:00
|
|
|
print('Done!')
|
|
|
|
|
|
|
|
async def loadMods(self):
|
|
|
|
for i in [s for s in os.listdir('modules') if ".py" in s]:
|
|
|
|
i = i[:-3]
|
|
|
|
print('loading', i)
|
|
|
|
m = __import__("modules."+i)
|
|
|
|
m = eval('m.'+i)
|
|
|
|
await m.init(self)
|
|
|
|
self.modules[i] = m
|
|
|
|
|
2020-04-06 00:21:10 +00:00
|
|
|
async def on_invite(self, channel, by):
|
|
|
|
print('{} invited me to {}!'.format(by, channel))
|
|
|
|
await self.join(channel)
|
2020-04-05 22:25:19 +00:00
|
|
|
|
2020-04-05 15:39:50 +00:00
|
|
|
|
|
|
|
async def on_message(self, chan, source, msg):
|
|
|
|
if source != self.nickname:
|
2020-04-05 22:25:19 +00:00
|
|
|
if msg == '!botlist':
|
|
|
|
await self.message(chan, 'hoinlo im oven im owned by lickthecheese and bake stuff for you')
|
|
|
|
for i in self.raw:
|
|
|
|
await self.raw[i](self, chan,source,msg)
|
|
|
|
if msg[:len(self.prefix)] == self.prefix:
|
2020-04-05 23:05:07 +00:00
|
|
|
msg = msg[len(self.prefix):]
|
2020-04-05 22:25:19 +00:00
|
|
|
cmd = msg.split(' ')[0]
|
2020-04-05 23:05:07 +00:00
|
|
|
msg = msg[len(cmd)+1:]
|
2020-04-05 22:25:19 +00:00
|
|
|
if cmd in self.cmd:
|
|
|
|
await self.cmd[cmd](self, chan, source, msg)
|
|
|
|
async def is_admin(self, nickname):
|
|
|
|
admin = False
|
|
|
|
|
|
|
|
# Check the WHOIS info to see if the source has identified with NickServ.
|
|
|
|
# This is a blocking operation, so use yield.
|
|
|
|
if nickname in self.admins:
|
|
|
|
info = await self.whois(nickname)
|
|
|
|
admin = info['identified']
|
|
|
|
|
|
|
|
return admin
|
|
|
|
|
2020-04-07 15:22:15 +00:00
|
|
|
async def on_private_message(self, trash, source, msg):
|
2020-04-09 22:56:51 +00:00
|
|
|
if source != self.nickname:
|
|
|
|
await self.message(source, 'Beep beep boop! im a bot, but i do not like privmsgs, please go to #bots or another channel that i am in!')
|
2020-04-05 15:39:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
client = Oven('oven', realname='Oven IRC Bot')
|
2020-04-05 22:25:19 +00:00
|
|
|
client.admins = ['lickthecheese']
|
|
|
|
client.prefix = 'ov '
|
2020-04-05 23:52:31 +00:00
|
|
|
client.run('team.tilde.chat', tls=True, tls_verify=False)
|
2020-04-05 15:39:50 +00:00
|
|
|
|