yuuzi261 / tweetcord Goto Github PK
View Code? Open in Web Editor NEWTweetcord is a twitter alert bot for discord, using the tweety-ns module.
License: MIT License
Tweetcord is a twitter alert bot for discord, using the tweety-ns module.
License: MIT License
I'm using Tweetcord! Thanks for the convenient repository!
I tried to make the bot display the list of registered users only on the server where the command was executed.
cogs/ListUsers.py
import discord
from discord import app_commands
from discord.ext import commands
import sqlite3
import os
class ListUsersCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
@app_commands.command(
name='list_users',
description='Lists registered Twitter usernames and their associated channels'
)
@commands.has_permissions(administrator=True)
async def list_users(self, itn: discord.Interaction):
server_id = itn.guild_id
db_path = os.path.join(os.getenv('DATA_PATH', ''), 'tracked_accounts.db')
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
cursor.execute("""
SELECT user.username, channel.id
FROM user
JOIN notification
ON user.id = notification.user_id
JOIN channel
ON notification.channel_id = channel.id
WHERE notification.server_id = ?
""", (str(server_id),))
user_channel_data = cursor.fetchall()
conn.close()
formatted_data = [f"{i+1}. ```{username}``` <#{channel_id}>" for i, (username, channel_id) in enumerate(user_channel_data)]
embed = discord.Embed(
title=f'Notice Add List ',
description='\n'.join(formatted_data),
color=0x778899
)
await itn.response.send_message(embed=embed)
async def setup(bot):
await bot.add_cog(ListUsersCog(bot))
notification.py add to changed 63line
add
server_id = str(itn.guild_id)
mention_str = mention.mention if mention else ''
changed
cursor.execute('INSERT INTO notification (user_id, channel_id, role_id) VALUES (?, ?, ?)', (str(new_user.id), str(channel.id), roleID))
to
cursor.execute('INSERT INTO notification (user_id, channel_id, role_id, mention, server_id) VALUES (?, ?, ?, ?, ?)', (str(new_user.id), str(channel.id), roleID, mention_str, server_id))
init_db,py
・notification table add server_id. mention
I posted it because it was a personally convenient feature! It's okay to use it!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.