WIP mostly running again
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
pandas
|
||||
# discord.py
|
||||
nextcord
|
||||
discord.py
|
||||
# nextcord
|
||||
nltk
|
||||
python-dotenv
|
||||
|
||||
@@ -9,3 +9,4 @@ beautifulsoup4
|
||||
requests
|
||||
lxml
|
||||
|
||||
rich
|
||||
@@ -2,7 +2,8 @@ import logging
|
||||
import random
|
||||
import re
|
||||
|
||||
from nextcord import Message, Client
|
||||
# from nextcord import Message, Client
|
||||
from discord import Message, Client
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@ import logging
|
||||
import re
|
||||
from random import choice
|
||||
|
||||
from nextcord import Client, Message
|
||||
from nextcord import utils
|
||||
# from nextcord import Client, Message
|
||||
# from nextcord import utils
|
||||
from discord import Client, Message, utils
|
||||
|
||||
from . import base, helpers
|
||||
|
||||
|
||||
@@ -2,14 +2,17 @@ import asyncio
|
||||
import logging
|
||||
import re
|
||||
import sqlite3
|
||||
from datetime import datetime, timedelta
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
import pandas as pd
|
||||
from nextcord import Client, Message, TextChannel
|
||||
from nextcord import RawReactionActionEvent, Emoji
|
||||
from nextcord import utils
|
||||
# from nextcord import Client, Message, TextChannel
|
||||
# from nextcord import RawReactionActionEvent, Emoji
|
||||
# from nextcord import utils
|
||||
|
||||
from discord import Client, Message, TextChannel
|
||||
from discord import RawReactionActionEvent, Emoji
|
||||
from discord import utils
|
||||
|
||||
from . import jokes
|
||||
from .reactions import ReactionData
|
||||
|
||||
@@ -2,9 +2,12 @@ import logging
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import pandas as pd
|
||||
from nextcord import Client, Message, Reaction
|
||||
from nextcord import TextChannel
|
||||
from nextcord.utils import AsyncIterator
|
||||
from discord import Client, Message, Reaction, TextChannel
|
||||
|
||||
# from nextcord import Client, Message, Reaction
|
||||
# from nextcord import TextChannel
|
||||
# from nextcord.utils import AsyncIterator
|
||||
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -15,7 +18,7 @@ async def message_gen(client: Client,
|
||||
days: int = None,
|
||||
after: datetime = None,
|
||||
around: datetime = None,
|
||||
oldest_first: bool = True) -> AsyncIterator[Message]:
|
||||
oldest_first: bool = True):
|
||||
if days is not None:
|
||||
after = (datetime.today() - timedelta(days=days)).astimezone()
|
||||
|
||||
@@ -38,7 +41,8 @@ async def message_gen(client: Client,
|
||||
async for msg in channel.history(**kwargs):
|
||||
yield msg
|
||||
for thread in channel.threads:
|
||||
LOGGER.info(f'Thread: {channel.category}: {channel.name}: {thread.name}')
|
||||
LOGGER.info(
|
||||
f'Thread: {channel.category}: {channel.name}: {thread.name}')
|
||||
async for msg in thread.history(**kwargs):
|
||||
yield msg
|
||||
else:
|
||||
@@ -60,7 +64,7 @@ def reaction_dict(reaction: Reaction):
|
||||
}
|
||||
|
||||
|
||||
async def reaction_gen(client: Client, **kwargs) -> AsyncIterator[Reaction]:
|
||||
async def reaction_gen(client: Client, **kwargs):
|
||||
async for msg in message_gen(client=client, **kwargs):
|
||||
for reaction in msg.reactions:
|
||||
yield reaction_dict(reaction)
|
||||
|
||||
@@ -5,7 +5,8 @@ from datetime import datetime, timedelta
|
||||
from pathlib import Path
|
||||
|
||||
import pandas as pd
|
||||
from nextcord import Message, Client
|
||||
# from nextcord import Message, Client
|
||||
from discord import Message, Client
|
||||
|
||||
from .msg import reaction_dict, message_gen
|
||||
|
||||
|
||||
46
src/main.py
46
src/main.py
@@ -1,47 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
import nextcord as discord
|
||||
from discord import Intents, Message, RawReactionActionEvent
|
||||
from dotenv import load_dotenv
|
||||
from nextcord import RawReactionActionEvent
|
||||
from rich.highlighter import NullHighlighter
|
||||
from rich.logging import RichHandler
|
||||
|
||||
from kwaylon import Kwaylon
|
||||
|
||||
if __name__ == '__main__':
|
||||
import logging
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
# https://docs.python.org/3/library/logging.html#logrecord-attributes
|
||||
format='[magenta]%(name)s[/] [cyan]%(funcName)s[/] %(message)s',
|
||||
datefmt='%Y-%m-%d %I:%M:%S %p',
|
||||
handlers=[
|
||||
RichHandler(
|
||||
highlighter=NullHighlighter(),
|
||||
markup=True,
|
||||
rich_tracebacks=True,
|
||||
tracebacks_suppress=['pandas'],
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
client = Kwaylon()
|
||||
for handler in logging.getLogger('discord.client').handlers:
|
||||
print(handler)
|
||||
|
||||
intents = Intents.default()
|
||||
intents.message_content = True
|
||||
client = Kwaylon(intents=intents)
|
||||
|
||||
@client.event
|
||||
async def on_ready():
|
||||
await client.handle_ready()
|
||||
# await client.data.scan_messages(
|
||||
# client=client,
|
||||
# limit=50,
|
||||
# # days=7,
|
||||
# )
|
||||
# chan = await client.fetch_channel(690588413543579649)
|
||||
# msg = await chan.fetch_message(936684979654623293)
|
||||
# logging.info(f'Msg: {msg.clean_content}')
|
||||
# await msg.reply(f'https://tenor.com/view/i-will-orange-county-jack-black-nodding-nod-gif-4984565')
|
||||
|
||||
|
||||
@client.event
|
||||
async def on_message(message: discord.Message):
|
||||
async def on_message(message: Message):
|
||||
await client.handle_message(message)
|
||||
|
||||
|
||||
@client.event
|
||||
async def on_raw_reaction_add(payload: RawReactionActionEvent):
|
||||
await client.handle_raw_reaction(payload)
|
||||
|
||||
|
||||
@client.event
|
||||
async def on_raw_reaction_remove(payload: RawReactionActionEvent):
|
||||
await client.handle_raw_reaction(payload)
|
||||
|
||||
|
||||
load_dotenv()
|
||||
client.run(os.getenv('DISCORD_TOKEN'))
|
||||
|
||||
Reference in New Issue
Block a user