-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbot.py
62 lines (48 loc) · 2.05 KB
/
bot.py
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
55
56
57
58
59
60
61
62
#!/usr/bin/env python
"""
RCTBot A Discord bot with Heroes of Newerth integration.
Copyright (C) 2020–2022 Danijel Jurešić
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
# TODO: Configuration variables for emojis and URLs.
# Cleanup needed.
import os
import asyncio
import discord
from hypercorn.config import Config
from hypercorn.asyncio import serve
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv()) # FIXME
bind_v4 = f'{os.getenv("ASGI_HOST", "127.0.0.1")}:{os.getenv("ASGI_PORT", "8000")}' # Defaults are already Hypercorn defaults.
config = Config()
config.bind = [bind_v4]
if __name__ == "__main__":
import rctbot
from rctbot.api.app import app, API
bot = rctbot.get_bot()
# TODO: Get this out of here.
@bot.event
async def on_ready():
print(
"{0} ({0.id}) reporting for duty from {1}! All shall respect the law that is my {2}!".format(
bot.user, bot.platform, rctbot.config.CONFIG_FILE
)
)
watching = discord.Activity(name="Heroes of Newerth", type=discord.ActivityType.watching)
# streaming = discord.Streaming(platform="Twitch", name="Heroes of Newerth", game="Heroes of Newerth", url="https://www.twitch.tv/", twitch_name="")
await bot.change_presence(activity=watching, status=discord.Status.dnd, afk=False)
print("------")
# Sigh...
API.bot = bot
loop = asyncio.get_event_loop()
loop.create_task(serve(app, config))
bot.run()