mirror of
https://git.wownero.com/lza_menace/lza-wowbot.git
synced 2024-08-15 03:23:51 +00:00
adding what I've got so far
This commit is contained in:
parent
646fdea846
commit
60db3a6309
2 changed files with 68 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@ freenode.pem
|
||||||
data
|
data
|
||||||
config.py
|
config.py
|
||||||
__pycache__
|
__pycache__
|
||||||
|
*.pyc
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
|
import sys, os
|
||||||
import pydle
|
import pydle
|
||||||
import monero
|
import monero
|
||||||
|
import requests
|
||||||
|
import random
|
||||||
|
|
||||||
import config
|
import config
|
||||||
|
|
||||||
|
@ -11,11 +14,55 @@ class IRCBot(pydle.Client):
|
||||||
async def on_message(self, target, source, message):
|
async def on_message(self, target, source, message):
|
||||||
if source == self.nickname:
|
if source == self.nickname:
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
print(f"Target: {target} - Source: {source} - Message: {message}")
|
||||||
|
|
||||||
if message.startswith('++help'):
|
if self.nickname in message:
|
||||||
await self.message(target, f"Hello new user, {source}! Don't worry, help is on the way! said: {message}")
|
imgs = [
|
||||||
elif config.BOT_NICKNAME in message:
|
"https://i.redd.it/f2z7ms4ai8751.png",
|
||||||
await self.message(target, f"Sup {source} - I'm not programmed to do anything just yet.")
|
"https://i.redd.it/j207p3l093751.png",
|
||||||
|
"https://i.redd.it/j3dq88hrmn651.jpg",
|
||||||
|
"https://i.redd.it/w24t2jwo6h651.jpg",
|
||||||
|
"https://i.redd.it/vi6bmspgl5651.png",
|
||||||
|
"https://i.redd.it/m392y5szvx551.jpg",
|
||||||
|
"https://i.redd.it/t59v1s3msu551.jpg",
|
||||||
|
"https://i.redd.it/x5ueaie8hs551.jpg",
|
||||||
|
"https://i.redd.it/3je54bq091551.png",
|
||||||
|
]
|
||||||
|
await self.message(target, f"Sup. I don't do a whole lot yet. Have a picture: {random.choice(imgs)}")
|
||||||
|
# elif message.startswith("!proposal "):
|
||||||
|
# split_msg = message.split()
|
||||||
|
# param = split_msg[1]
|
||||||
|
# print(param)
|
||||||
|
# print(split_msg)
|
||||||
|
# if isinstance(param, int):
|
||||||
|
# r = requests.get("https://funding.wownero.com/api/1/proposals?status=2")
|
||||||
|
# if r.status_code == 200:
|
||||||
|
# found = False
|
||||||
|
# for prop in r.json()["data"]:
|
||||||
|
# if prop["id"] == param:
|
||||||
|
# found = True
|
||||||
|
# await self.message(target, f"{prop}")
|
||||||
|
# if not found:
|
||||||
|
# await self.message(target, f"There's no proposal with that ID")
|
||||||
|
# else:
|
||||||
|
# await self.message(target, f"I didn't get a valid response from the WFS API. Debug: {r.content}")
|
||||||
|
# else:
|
||||||
|
# await self.message(target, f"You're supposed to provide a number ya dingus!")
|
||||||
|
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)
|
||||||
|
@ -28,10 +75,20 @@ class IRCBot(pydle.Client):
|
||||||
print("info: ", info)
|
print("info: ", info)
|
||||||
return admin
|
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)
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
try:
|
||||||
|
print(f"[+] Starting IRC bot connecting to {config.IRC_HOST}")
|
||||||
|
client = IRCBot(
|
||||||
|
nickname=config.BOT_NICKNAME,
|
||||||
|
sasl_mechanism = "EXTERNAL",
|
||||||
|
tls_client_cert = "./freenode.pem",
|
||||||
|
)
|
||||||
|
client.run(config.IRC_HOST, tls=True, tls_verify=False)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print('Adios')
|
||||||
|
try:
|
||||||
|
sys.exit(0)
|
||||||
|
except SystemExit:
|
||||||
|
os._exit(0)
|
||||||
|
|
Loading…
Reference in a new issue