adding bot code so far

This commit is contained in:
lza_menace 2020-07-08 00:58:30 -07:00
parent 2745b432a1
commit 646fdea846
3 changed files with 54 additions and 0 deletions

0
ircbot/__init__.py Normal file
View file

37
ircbot/bot.py Normal file
View file

@ -0,0 +1,37 @@
import pydle
import monero
import config
class IRCBot(pydle.Client):
async def on_connect(self):
for room in config.ROOMS:
await self.join(room)
async def on_message(self, target, source, message):
if source == self.nickname:
return
if message.startswith('++help'):
await self.message(target, f"Hello new user, {source}! Don't worry, help is on the way! said: {message}")
elif config.BOT_NICKNAME in message:
await self.message(target, f"Sup {source} - I'm not programmed to do anything just yet.")
# isadmin = await self.is_admin(source)
# print(isadmin)
async def is_admin(self, nickname):
admin = False
if nickname in config.ADMIN_NICKNAMES:
info = await self.whois(nickname)
admin = info['identified']
print("info: ", info)
return admin
client = IRCBot(
nickname=config.BOT_NICKNAME,
sasl_mechanism = "EXTERNAL",
tls_client_cert = "./freenode.pem",
)
client.run(config.IRC_HOST, tls=True, tls_verify=False)

17
ircbot/config.example.py Normal file
View file

@ -0,0 +1,17 @@
# Bot meta
BOT_NICKNAME = 'lza-wowbot'
ROOMS = ['wownero', 'secret-bot-testing-facility']
ADMIN_NICKNAMES = ['lza_menace']
# Monero Daemon
DAEMON_HOST = 'endpoint or ip address' # ip of the node
DAEMON_PORT = 34568 # port the node accepts for rpc calls
DAEMON_USER = 'username'
DAEMON_PASS = 'password'
# Security
PASSWORD_SALT = 'salt here' # database salts
SECRET_KEY = 'secret session key here' # encrypts the session token
# IRC
IRC_HOST = 'ajnvpgl6prmkb7yktvue6im5wiedlz2w32uhcwaamdiecdrfpwwgnlqd.onion'