-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample_target.py
More file actions
54 lines (40 loc) · 1.68 KB
/
example_target.py
File metadata and controls
54 lines (40 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
This bot is a sample bot that is used to demonstrate the testing functionality.
It does not run the tests, just exists to have tests run on it.
Run with:
python example_target.py TARGET_TOKEN
"""
import asyncio
import sys
import os
import discord
from github import Github
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN')
GITHUB_TOKEN = os.getenv('GITHUB_TOKEN')
git = Github(GITHUB_TOKEN)
client = discord.Client()
@client.event
async def on_ready():
print("Ready")
text_channel_id = None
@client.event
async def on_message(message):
if message.author.id is client.user.id:
return
sent = None
# Hello Command
if message.content == "!git hello":
await asyncio.sleep(1)
sent = await message.channel.send('> :wave: Hi there ' + str(client.user.name))
# Single issue command
if message.content == "!git issue MLH-Fellowship/github-discord-bot 15":
repo = git.get_repo("MLH-Fellowship/github-discord-bot")
issue = repo.get_issue(number=int(15))
await message.channel.send('> Issue Title: ' + issue.title + '\n > Issue Number: ' + str(issue.number) +'\n > Issue Link: https://github.com/' + repo.name + '/issues/' + str(issue.number))
# PULL REQUEST COMMAND
if message.content.startswith("!git pull_request MLH-Fellowship/github-discord-bot 27"):
repo=''
repo = git.get_repo("MLH-Fellowship/github-discord-bot")
pull = repo.get_pull(number=int(27))
await message.channel.send('> Pull Request Title: ' + pull.title + '\n > Pull Request Number: ' + str(pull.number) +'\n > Pull Request Link: https://github.com/' + repo.name + '/pull/' + str(pull.number))
client.run(sys.argv[1])