-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.py
41 lines (36 loc) · 1.75 KB
/
main.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
#! /usr/bin/env python3
import json
import os
from framework import Bot
from config.startup import startup
# initialisation + grab credentials
f = open("config" + os.sep + "bot_config.conf", "r")
config = json.loads(f.read())
f.close()
if not config["password"] or config["password"] == "password":
print("Please go to http://osu.ppy.sh/p/irc/ and generate your username and password!")
while not config["password"] or config["password"] == "password":
config["username"] = input("Enter your irc username: ")
password = input("Enter your irc password: ")
confirm = input("Enter your irc password again to confirm: ")
if confirm == password:
config["password"] = password
else:
print("Passwords do not match!")
if input("Would you like to save these credentials for next time? [y/n]: ").lower() in ["y", "yes"]:
print("You can change your credentials in the future by modifying ./config/bot_config.conf")
f = open("config" + os.sep + "bot_config.conf", "w")
f.write(json.dumps(config).replace(", ", ",\n").replace("{", "{\n", 1)[:-1] + "\n}")
f.close()
# set up bot
try:
os.mkdir("config" + os.sep + "logs")
except:
pass
bot = Bot(username=config["username"], password=config["password"], host=config["irc_host"], port=config["irc_port"], server_ip=config["server_ip"], message_log_length=config["message_log_length"], logging=config["logging"], verbose=config["verbose"])
bot.set_webapp_port(config["server_port"])
bot.set_websocket_port(config["websocket_port"])
bot.get_sock().set_period(config["send_period"])
bot.get_sock().set_msg_num(config["send_cap"])
bot.set_authenticate(config["server_authentication"])
startup(bot)