From 646fdea846bdab9559891e2ff335bd14addead9d Mon Sep 17 00:00:00 2001 From: lza_menace Date: Wed, 8 Jul 2020 00:58:30 -0700 Subject: [PATCH] adding bot code so far --- ircbot/__init__.py | 0 ircbot/bot.py | 37 +++++++++++++++++++++++++++++++++++++ ircbot/config.example.py | 17 +++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 ircbot/__init__.py create mode 100644 ircbot/bot.py create mode 100644 ircbot/config.example.py diff --git a/ircbot/__init__.py b/ircbot/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ircbot/bot.py b/ircbot/bot.py new file mode 100644 index 0000000..f370e51 --- /dev/null +++ b/ircbot/bot.py @@ -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) diff --git a/ircbot/config.example.py b/ircbot/config.example.py new file mode 100644 index 0000000..5faf4d4 --- /dev/null +++ b/ircbot/config.example.py @@ -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'