Skip to content

Commit fb6d0e3

Browse files
committed
more cmds and webhook init
1 parent 23f42f1 commit fb6d0e3

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-4
lines changed

bot.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import subprocess
44
import datetime
55
import urllib.request, json
6+
import requests
67

78
bot = commands.Bot(
89
irc_token="oauth:"+os.environ['tip'],
@@ -26,14 +27,11 @@ async def event_message(message):
2627
async def test_command(ctx):
2728
await ctx.send(f'Hello {ctx.author.name}')
2829

29-
@bot.command(name='agenda', aliases=['c'])
30+
@bot.command(name='agenda', aliases=['a'])
3031
async def agenda_command(ctx):
3132
with urllib.request.urlopen("https://raw.githubusercontent.com/hackbacc/schedule/master/json/schedule.json") as url:
3233
data = json.loads(url.read().decode())
3334

34-
# with open('json/schedule.json', 'r') as f:
35-
# data = json.load(f)
36-
3735
to_date = datetime.datetime.now().date()
3836
agendas = []
3937

@@ -47,4 +45,20 @@ async def agenda_command(ctx):
4745

4846
for agenda in agendas:
4947
await ctx.send(agenda)#.encode('utf-8'))
48+
49+
@bot.command(name='discord', aliases=['d'])
50+
async def discord_command(ctx):
51+
await ctx.send("https://discord.gg/9pQgEEx")
52+
53+
@bot.command(name='github', aliases=['g'])
54+
async def github_command(ctx):
55+
await ctx.send("Personal - https://github.com/markroxor")
56+
await ctx.send("Channel - https://github.com/hackbacc")
57+
58+
@bot.command(name='projects', aliases=['p'])
59+
async def projects_command(ctx):
60+
payload = requests.get('https://api.github.com/users/hackbacc/repos').text
61+
for project in json.loads(payload):
62+
await ctx.send(project['full_name'] + " - " + project['html_url'] + " - " + str(project['description']))
63+
5064
bot.run()

webhook.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
########################### REVIEW LATER ################################
2+
from http.server import HTTPServer, BaseHTTPRequestHandler
3+
import json
4+
5+
from io import BytesIO
6+
7+
8+
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
9+
10+
def do_GET(self):
11+
self.send_response(200)
12+
self.end_headers()
13+
self.wfile.write(b'Hello, world!')
14+
15+
def do_POST(self):
16+
content_length = int(self.headers['Content-Length'])
17+
body = self.rfile.read(content_length)
18+
self.send_response(200)
19+
self.end_headers()
20+
response = BytesIO()
21+
response.write(b'This is POST request. ')
22+
response.write(b'Received: ')
23+
response.write(body)
24+
25+
body = json.loads(body)
26+
if body['repository']['full_name'] == 'hackbacc/hackbot':
27+
pass
28+
29+
self.wfile.write(response.getvalue())
30+
31+
32+
httpd = HTTPServer(('localhost', 6006), SimpleHTTPRequestHandler)
33+
httpd.serve_forever()
34+

0 commit comments

Comments
 (0)