-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
49 lines (37 loc) · 1.32 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
42
43
44
45
46
47
48
49
import argparse
import sys
import tomllib
from argparse import Namespace
from loguru import logger
from buttify.billy1buttsbot import Billy1ButtsBot
from buttify.settings import Settings
def main(args: Namespace) -> None:
with open(args.config, "rb") as f:
config = tomllib.load(f)["tool"]["billy1buttsbot"]
# Set the verbosity of the logger.
if config['verbose']:
logger.remove()
logger.add(sys.stderr, level="DEBUG")
else:
logger.remove()
logger.add(sys.stderr, level="INFO")
token = input("Enter the Twitch OAuth token: ")
logger.debug("Verbose logging enabled.")
settings = Settings(
channel=str(config['channel']),
user=config['username'],
token=token,
ignore_users=list(config['ignore_users']),
chance=float(config["chance_of_buttification"]),
dry_run=config["dry_run"],
)
if settings.dry_run:
logger.warning("Running in dry-run mode. No messages will be sent.")
bot = Billy1ButtsBot(settings)
logger.info("Starting Billy1ButtsBot... press Ctrl+C to stop.")
bot.run()
if __name__ == '__main__':
parser = argparse.ArgumentParser('Billy1ButtsBot service')
parser.add_argument('--config', default='pyproject.toml', help='Configuration')
args = parser.parse_args()
main(args)