add boilerplate code

main
lza_menace 4 years ago
parent 91932d2f13
commit 05d08bfc5f

3
.gitignore vendored

@ -127,3 +127,6 @@ dmypy.json
# Pyre type checker # Pyre type checker
.pyre/ .pyre/
# Extra data
data

@ -1,2 +1,15 @@
# monerosupport # monerosupport
An IRC bot for helping people on /r/monerosupport An IRC bot for helping people on /r/monerosupport
todo
```
# Setup
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# Run
python3 -m supportbot
```

@ -0,0 +1,4 @@
praw
peewee
pure-sasl
pydle

@ -0,0 +1,10 @@
import logging
from supportbot import run_bot
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s'
)
if __name__ == '__main__':
run_bot()

@ -0,0 +1,41 @@
import sys, os
import pydle
from supportbot import config
from supportbot import db
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
else:
print(f"Target: {target} - Source: {source} - Message: {message}")
if self.nickname in message:
await self.message(target, f"Sup. I'm not very helpful yet, but getting there."
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
def run_bot():
try:
print(f"[+] Starting IRC bot connecting to {config.IRC_HOST}...\n")
client = IRCBot(nickname=config.BOT_NICKNAME)
client.run(config.IRC_HOST, tls=True, tls_verify=False)
except KeyboardInterrupt:
print(' - Adios')
try:
sys.exit(0)
except SystemExit:
os._exit(0)

@ -0,0 +1,17 @@
# Bot meta
BOT_NICKNAME = 'mybotname'
ROOMS = ['#monero-support']
ADMIN_NICKNAMES = ['lza_menace', 'needmoney90']
# DB
SQLITE_DB_PATH = './data/supportbot.sqlite'
# IRC
IRC_HOST = 'ajnvpgl6prmkb7yktvue6im5wiedlz2w32uhcwaamdiecdrfpwwgnlqd.onion'
# Reddit
PRAW_CLIENT_SECRET = 'xxxxxxxx'
PRAW_CLIENT_ID = 'xxxxxxxx'
PRAW_USERNAME = 'xxxxxxxx'
PRAW_PASSWORD = 'xxxxxxxx'
PRAW_USER_AGENT = 'r-monerosupport-dev-python'

@ -0,0 +1,15 @@
import datetime
from peewee import *
import config
db = SqliteDatabase(config.SQLITE_DB_PATH)
class BaseModel(Model):
class Meta:
database = db
class SupportRequest(BaseModel):
reddit_user = CharField()
solved = BooleanField(default=False)
# todo...
Loading…
Cancel
Save