adding registration feature

This commit is contained in:
lza_menace 2020-07-13 00:35:09 -07:00
parent 55137d2afb
commit 7728b2610f
2 changed files with 68 additions and 57 deletions

View file

@ -1,10 +1,11 @@
import sys, os import sys, os
import pydle import pydle
import monero
import requests import requests
import random import random
import config import config
import wownero
import db
class IRCBot(pydle.Client): class IRCBot(pydle.Client):
async def on_connect(self): async def on_connect(self):
@ -18,7 +19,25 @@ class IRCBot(pydle.Client):
print(f"Target: {target} - Source: {source} - Message: {message}") print(f"Target: {target} - Source: {source} - Message: {message}")
if self.nickname in message: if self.nickname in message:
await self.message(target, f"Sup. I don't do a whole lot yet. Have a picture: {random.choice(config.IMAGES)}") await self.message(target, f"Sup. I'm not very helpful yet, but getting there.")
elif message.startswith("meme"):
await self.message(target, random.choice(config.IMAGES))
elif message.startswith("register"):
wallet = wownero.Wallet()
if not wallet.connected:
await self.message(target, f"My connection to the wallet RPC endpoint is broken so I can't do that right now. Paging: {config.ADMIN_NICKNAMES}")
if db.User.filter(irc_nick=source):
await self.message(target, f"You are already registered. FOH.")
else:
new_address = wallet.new_address(account=config.ACTIVE_WALLET_ACCOUNT, label=source)
u = db.User(
irc_nick=source,
account_index=config.ACTIVE_WALLET_ACCOUNT,
address_index=new_address[0]
)
u.save()
print({"type": "registration", "user": source, "address_index": new_address[0]})
await self.message(target, f"Grats bra, you're locked and loaded. Send funds to {new_address[1]}")
# elif message.startswith("!proposal "): # elif message.startswith("!proposal "):
# split_msg = message.split() # split_msg = message.split()
# param = split_msg[1] # param = split_msg[1]
@ -43,27 +62,6 @@ class IRCBot(pydle.Client):
strip_last = message.split()[1][:-1] strip_last = message.split()[1][:-1]
strip_first = strip_last[1:] strip_first = strip_last[1:]
await self.message(target, f"WTF is up {strip_first}! Stay tuned for more cool ass bot shit goin down!") await self.message(target, f"WTF is up {strip_first}! Stay tuned for more cool ass bot shit goin down!")
elif message.startswith("!supply"):
r = requests.get("https://funding.wownero.com/api/1/wow/supply")
if r.status_code == 200:
data = r.json()["data"]
await self.message(target, f"The current total supply of WOW is {data}")
else:
await self.message(target, f"I didn't get a valid response from the WFS API. Debug: {r.content}")
elif message.startswith("!proposals"):
r = requests.get("https://funding.wownero.com/api/1/proposals?status=2")
if r.status_code == 200:
proposals = []
print(r.json())
print(r.content)
print(r.json()['data'])
for prop in r.json()["data"]:
print(prop)
proposals.append(f"{prop['id']}. {prop['headline']}")
print(proposals)
await self.message(target, f"Here are the proposals needing fundings: {', '.join(proposals)}")
else:
await self.message(target, f"I didn't get a valid response from the WFS API. Debug: {r.content}")
# isadmin = await self.is_admin(source) # isadmin = await self.is_admin(source)
# print(isadmin) # print(isadmin)

View file

@ -3,16 +3,30 @@ BOT_NICKNAME = 'lza-wowbot'
ROOMS = ['wownero', 'secret-bot-testing-facility'] ROOMS = ['wownero', 'secret-bot-testing-facility']
ADMIN_NICKNAMES = ['lza_menace'] ADMIN_NICKNAMES = ['lza_menace']
# Monero Daemon # Wownero Daemon
DAEMON_HOST = 'endpoint or ip address' # ip of the node DAEMON_HOST = 'endpoint or ip address' # ip of the node
DAEMON_PORT = 34568 # port the node accepts for rpc calls DAEMON_PORT = 34568 # port the node accepts for rpc calls
DAEMON_PROTO = 'http' # protocol used for communications
DAEMON_USER = 'username' DAEMON_USER = 'username'
DAEMON_PASS = 'password' DAEMON_PASS = 'password'
# Wownero Wallet
WALLET_HOST = 'endpoint or ip address' # ip of the wallet host
WALLET_PORT = 8888 # port the wallet accepts for rpc calls
WALLET_PROTO = 'http' # protocol used for communications
WALLET_USER = 'username'
WALLET_PASS = 'password'
# Registration
ACTIVE_WALLET_ACCOUNT = 0
# Security # Security
PASSWORD_SALT = 'salt here' # database salts PASSWORD_SALT = 'salt here' # database salts
SECRET_KEY = 'secret session key here' # encrypts the session token SECRET_KEY = 'secret session key here' # encrypts the session token
# DB
SQLITE_DB_PATH = './data/wowbot-db.sqlite'
# IRC # IRC
IRC_HOST = 'ajnvpgl6prmkb7yktvue6im5wiedlz2w32uhcwaamdiecdrfpwwgnlqd.onion' IRC_HOST = 'ajnvpgl6prmkb7yktvue6im5wiedlz2w32uhcwaamdiecdrfpwwgnlqd.onion'
TELEGRAM_BRIDGE_NAME = 'WowBridge' TELEGRAM_BRIDGE_NAME = 'WowBridge'
@ -20,36 +34,35 @@ TELEGRAM_JOIN_SUBSTR = 'has joined the Telegram Group'
# MEMES # MEMES
IMAGES = [ IMAGES = [
'https://i.imgflip.com/44lwio.jpg', 'https://files.lzahq.tech/wow/memes/44lwio.jpg',
'https://i.imgur.com/1j0lAMZ.png', 'https://files.lzahq.tech/wow/memes/1j0lAMZ.png',
'https://i.imgur.com/3IFtDIQ.jpg', 'https://files.lzahq.tech/wow/memes/3IFtDIQ.jpg',
'https://i.imgur.com/49W12pr.png', 'https://files.lzahq.tech/wow/memes/49W12pr.png',
'https://i.imgur.com/Cly8ERi.jpg', 'https://files.lzahq.tech/wow/memes/Cly8ERi.jpg',
'https://i.imgur.com/DK7fepa.jpg', 'https://files.lzahq.tech/wow/memes/DK7fepa.jpg',
'https://i.imgur.com/G5lVTQX.jpg', 'https://files.lzahq.tech/wow/memes/G5lVTQX.jpg',
'https://i.imgur.com/HYzcRr2.png', 'https://files.lzahq.tech/wow/memes/HYzcRr2.png',
'https://i.imgur.com/Kcmaage.png', 'https://files.lzahq.tech/wow/memes/Kcmaage.png',
'https://i.imgur.com/MS4odnv.gif', 'https://files.lzahq.tech/wow/memes/MS4odnv.gif',
'https://i.imgur.com/MXJ2slS.png', 'https://files.lzahq.tech/wow/memes/MXJ2slS.png',
'https://i.imgur.com/SPhn9u0.png', 'https://files.lzahq.tech/wow/memes/SPhn9u0.png',
'https://i.imgur.com/WQUmuHl.jpg', 'https://files.lzahq.tech/wow/memes/WQUmuHl.jpg',
'https://i.imgur.com/c16qByl.png', 'https://files.lzahq.tech/wow/memes/c16qByl.png',
'https://i.imgur.com/ck7Uav1.jpg', 'https://files.lzahq.tech/wow/memes/ck7Uav1.jpg',
'https://i.imgur.com/favicon.ico', 'https://files.lzahq.tech/wow/memes/h3PjuVl.jpg',
'https://i.imgur.com/h3PjuVl.jpg', 'https://files.lzahq.tech/wow/memes/i5I0Qrm.jpg',
'https://i.imgur.com/i5I0Qrm.jpg', 'https://files.lzahq.tech/wow/memes/i9gKtXe.jpg',
'https://i.imgur.com/i9gKtXe.jpg', 'https://files.lzahq.tech/wow/memes/iSXJluW.jpg',
'https://i.imgur.com/iSXJluW.jpg', 'https://files.lzahq.tech/wow/memes/ixvottX.png',
'https://i.imgur.com/ixvottX.png', 'https://files.lzahq.tech/wow/memes/o56reOl.jpg',
'https://i.imgur.com/o56reOl.jpg', 'https://files.lzahq.tech/wow/memes/oYB41Hk.png',
'https://i.imgur.com/oYB41Hk.png', 'https://files.lzahq.tech/wow/memes/q7n2rEZ.png',
'https://i.imgur.com/q7n2rEZ.png', 'https://files.lzahq.tech/wow/memes/t0CSrfo.png',
'https://i.imgur.com/t0CSrfo.png', 'https://files.lzahq.tech/wow/memes/uDrpKJ8.png',
'https://i.imgur.com/uDrpKJ8.png', 'https://files.lzahq.tech/wow/memes/uhQGV7b.jpg',
'https://i.imgur.com/uhQGV7b.jpg', 'https://files.lzahq.tech/wow/memes/utjI6MW.png',
'https://i.imgur.com/utjI6MW.png', 'https://files.lzahq.tech/wow/memes/v7clSBi.png',
'https://i.imgur.com/v7clSBi.png', 'https://files.lzahq.tech/wow/memes/vQ9v2ub.png',
'https://i.imgur.com/vQ9v2ub.png', 'https://files.lzahq.tech/wow/memes/wW0ueSf.gif',
'https://i.imgur.com/wW0ueSf.gif', 'https://files.lzahq.tech/wow/memes/xyiE9vx.mp4',
'https://i.imgur.com/xyiE9vx.mp4',
] ]