Compare commits
No commits in common. "36485fbda858fbd5521fce601a5dab5f64136e15" and "1e30e9bddce00fc6a17f6881d3b27673c7632345" have entirely different histories.
36485fbda8
...
1e30e9bddc
5 changed files with 1 additions and 60 deletions
|
|
@ -13,4 +13,3 @@ dead simple last.fm bot
|
|||
- add collage generation
|
||||
- fix attachment generation and upload
|
||||
- temporary fix: upload and link to catbox urls
|
||||
- permanent fix: fork and update nerimity library
|
||||
|
|
|
|||
19
bot.py
19
bot.py
|
|
@ -7,11 +7,9 @@ import pylast
|
|||
|
||||
class Bot(nerimity.Client):
|
||||
"""Extended client class for extra functionality."""
|
||||
def __init__(self, lastfm_api_key: str, lastfm_api_secret: str, owner_id: int = None, db_file: str = "database.db", *args, **kwargs):
|
||||
def __init__(self, lastfm_api_key: str, lastfm_api_secret: str, db_file: str = "database.db", *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.owner_id = owner_id
|
||||
|
||||
# initialize last.fm client
|
||||
self.lastfm = pylast.LastFMNetwork(
|
||||
api_key = lastfm_api_key,
|
||||
|
|
@ -21,7 +19,6 @@ class Bot(nerimity.Client):
|
|||
self.db = None
|
||||
self.db_file = db_file
|
||||
|
||||
|
||||
def load_commands(self, commands_dir: str):
|
||||
for filename in os.listdir(commands_dir):
|
||||
if filename.endswith(".py") and not filename.startswith("_"):
|
||||
|
|
@ -31,20 +28,6 @@ class Bot(nerimity.Client):
|
|||
module.setup(self)
|
||||
print(f"Loaded {module_name}")
|
||||
print("Registered commands:", self.commands)
|
||||
|
||||
def is_owner(self, user: nerimity.Member = None):
|
||||
if not user: return None
|
||||
else:
|
||||
if user.id == self.owner_id: return True
|
||||
else: return False
|
||||
|
||||
def _process_slash_commands(self, message: nerimity.Message):
|
||||
if message.author.id == self.account.id: return
|
||||
super()._process_slash_commands(message)
|
||||
|
||||
async def _process_commands(self, message: nerimity.Message):
|
||||
if message.author.id == self.account.id: return
|
||||
await super()._process_commands(message)
|
||||
|
||||
async def init_db(self):
|
||||
print("Initializing database...")
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
import nerimity
|
||||
|
||||
import bot
|
||||
import utils as u
|
||||
|
||||
def setup(bot: bot.Bot):
|
||||
@bot.command(name="echo")
|
||||
async def echo(ctx: nerimity.Context, *text: str):
|
||||
print(bot.is_owner(ctx.author))
|
||||
if not bot.is_owner(ctx.author):
|
||||
print("returned")
|
||||
return
|
||||
if not text:
|
||||
await ctx.send(u.error_msg("Contents are empty."))
|
||||
return
|
||||
|
||||
try: await ctx.send(" ".join(text))
|
||||
except Exception as e:
|
||||
print(e)
|
||||
await ctx.send(u.error_msg(f"Unknown error:\n`{e}`"))
|
||||
|
||||
@bot.command(name="post")
|
||||
async def post(ctx: nerimity.Context, *text: str):
|
||||
print(bot.is_owner(ctx.author))
|
||||
if not bot.is_owner(ctx.author):
|
||||
print("returned")
|
||||
return
|
||||
if not text:
|
||||
await ctx.send(u.error_msg("Contents are empty."))
|
||||
return
|
||||
|
||||
try:
|
||||
await ctx.send(f"Creating post:\n```markdown\n{" ".join(text)}\n```")
|
||||
# post = nerimity.Post.create_post(content=" ".join(text))
|
||||
# print(post)
|
||||
await ctx.send(u.good_msg(f"Post created!!"))
|
||||
except Exception as e:
|
||||
print(e)
|
||||
await ctx.send(u.error_msg(f"Unknown error:\n`{e}`"))
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
token = "NerimityTokenHere"
|
||||
owner_id = 1234567890
|
||||
api_key = "LastFmApiKeyHere"
|
||||
api_secret = "LastFmApiSecretHere"
|
||||
|
|
|
|||
1
main.py
1
main.py
|
|
@ -9,7 +9,6 @@ with open("config.toml", "rb") as f:
|
|||
bot = bot.Bot(
|
||||
prefix = '!',
|
||||
token = config['token'],
|
||||
owner_id = config['owner_id'],
|
||||
lastfm_api_key = config['api_key'],
|
||||
lastfm_api_secret = config['api_secret']
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue