-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot.py
executable file
·79 lines (66 loc) · 2.49 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python3.8
"""This is a duplicate of the Fanfic Rec Bot, but it works better.
Required files are: bot.py, config.py, abstractor.py, messages.py, parser.py
To run the bot, execute bot.py and leave it running.
config.py must contain the bot token as a variable, token.
To ignore existing bots, put their user IDs in config.py in bots_ignore.
To disable deleting bot messages by replying with "delete",
put the server ID in config.py in servers_no_deletion.
To disable getting info about fics by replying to series messages,
put the server ID in config.py in servers_no_reacts.
These must be blank lists or sets, otherwise.
quihi
"""
import abstractor
import config
import discord
import logging
import sys
def main():
"""Run the discord bot."""
# set up logging
logger = logging.getLogger('discord')
logger.setLevel(logging.WARNING)
handler = logging.FileHandler(
filename='discord.log', encoding='utf-8', mode='a')
handler.setFormatter(logging.Formatter(
'%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)
logger = logging.getLogger('servers')
logger.setLevel(logging.INFO)
handler = logging.FileHandler(
filename='servers.log', encoding='utf-8', mode='a')
handler.setFormatter(logging.Formatter(
'%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
logger.addHandler(handler)
# create discord client
intents = discord.Intents(messages=True, reactions=True, guilds=True)
activity = discord.Activity(
name='@me help',
type=discord.ActivityType.playing)
description = "Posts information about fanfiction. Contact {} for details.\
\nhttps://github.com/quihi/fanfiction-abstractor"\
.format(config.name)
client = abstractor.Abstractor(
intents=intents, activity=activity, description=description)
# run the bot
print(sys.version)
print("Completed setup!")
client.run(config.token)
if __name__ == '__main__':
main()
"""
TODO:
- add way more configuration
- limit summary length, how many blurbs are posted, etc.
- use sqlite or at least pickling for configuration
- handle external bookmarks
- change characters to additional characters
- potentially add comma at end of tag lists before ellipsis
- flip to make weird stuff opt-in
- switch to aiohttp library
- something with what chapter is linked?
- add bookmark count for series?
- add more info on series (fandoms, tags, etc. off author page)
- test Lomonaaeren for that
"""