Giter Club home page Giter Club logo

robodanny's Introduction

R. Danny

A personal bot that runs on Discord.

Running

I would prefer if you don't run an instance of my bot. Just call the join command with an invite URL to have it on your server. The source here is provided for educational purposes for discord.py.

Nevertheless, the installation steps are as follows:

  1. Make sure to get Python 3.8 or higher

This is required to actually run the bot.

  1. Set up venv

Just do python3.8 -m venv venv

  1. Install dependencies

This is pip install -U -r requirements.txt

  1. Create the database in PostgreSQL

You will need PostgreSQL 9.5 or higher and type the following in the psql tool:

CREATE ROLE rdanny WITH LOGIN PASSWORD 'yourpw';
CREATE DATABASE rdanny OWNER rdanny;
CREATE EXTENSION pg_trgm;
  1. Setup configuration

The next step is just to create a config.py file in the root directory where the bot is with the following template:

client_id   = '' # your bot's client ID
token = '' # your bot's token
debug = False # used to disable certain features
carbon_key = '' # your bot's key on carbon's site
bots_key = '' # your key on bots.discord.pw
postgresql = 'postgresql://user:password@host/database' # your postgresql info from above
challonge_api_key = '...' # for tournament cog
stat_webhook = ('<webhook_id>','<webhook_token>') # a webhook to a channel for bot stats.
# when you generate your webhook, take the token and ID from the URL like so:
# https://discord.com/api/webhooks/<id>/<token>
github_token = '' # your github API personal token
open_collective_token = '' # your open collective personal token
oc_discord_client_id = '' # the client ID of the Open Collective Discord Integration application
oc_discord_client_secret = '' # the client secret of the Open Collective Discord Integration application

A lot of these configuration variables are undocumented precisely because the bot is meant for personal use.

  1. Configuration of database

To configure the PostgreSQL database for use by the bot, go to the directory where launcher.py is located, and run the script by doing python3.8 launcher.py db init

Privacy Policy and Terms of Service

Discord requires me to make one of these.

There isn't really anything to note. No personal data is stored.

robodanny's People

Contributors

abstractumbra avatar advaith1 avatar avayert avatar bijij avatar daudd avatar diceroll123 avatar erickang21 avatar euphyzr avatar fogapod avatar gx1285 avatar harmon758 avatar ioistired avatar itslychee avatar jonasbohmann avatar ktraw2 avatar kyb3r avatar leocx1000 avatar lmaotrigine avatar minndevelopment avatar monty-dev avatar ncplayz avatar nihaals avatar raidandfade avatar rapptz avatar rf20008 avatar rom1-j avatar tookender avatar ukaigo avatar willy-c avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

robodanny's Issues

Banned from R. Danny

Good day,

So this happened a while back and I can't find any sort of support server so I came here. Quite a while back I believe I ended up blacklisting myself from the bot by using the ?star random command too much (my Discord handle is HeyItsSirius#0019). Just wasn't sure if I could get access to the bot again or what

Starboard should include a quick link to the starred message

Since Discord allows linking to specific messages using a link structured as https://discordapp.com/channels/{server.id}/{channel.id}/{message.id}, Danny should probably include that sort of link in the starboard message, to make it easier to get some context.

Please help me with this issue

I keep getting

Could not load cogs.meta. Traceback (most recent call last): File "launcher.py", line 112, in init importlib.import_module(ext) File "C:\Users\super\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 783, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "C:\Users\super\Desktop\RoboDanny\Rdanny\RoboDanny\cogs\meta.py", line 2, in <module> from .utils import checks, formats, time File "C:\Users\super\Desktop\RoboDanny\Rdanny\RoboDanny\cogs\utils\time.py", line 3, in <module> from dateutil.relativedelta import relativedelta ValueError: source code string cannot contain null bytes

If someone help me I will join the discord again.

it says "ModuleNotFoundError: No module named 'discord'"

When I run py launcher.py db init (I know that's not what it says in the README file but I am on windows) it gives this
Traceback (most recent call last): File "launcher.py", line 6, in <module> import discord ModuleNotFoundError: No module named 'discord'

Please help me fix this

Issue with bothealth command

UnboundLocalError: local variable 'all_tasks' referenced before assignment

Getting this error when running the command.

AttributeError: module 'config' has no attribute 'stat_webhook'

AttributeError: module 'config' has no attribute 'stat_webhook'

the following is a part of stats.py

    @discord.utils.cached_property
    def webhook(self):
        wh_id, wh_token = self.bot.config.stat_webhook
        hook = discord.Webhook.partial(id=wh_id, token=wh_token, adapter=discord.AsyncWebhookAdapter(self.bot.session))
        return hook

the error is thrown from this function - line 3 (RoboDanny-rewrite\cogs\stats.py, line 142)

following is the error:

Unhandled exception in internal background task 'gateway_worker'.
Traceback (most recent call last):
  File "C:\Users\billy\AppData\Roaming\Python\Python38\site-packages\discord\ext\tasks\__init__.py", line 101, in _loop
    await self.coro(*args, **kwargs)
  File "C:\Users\billy\OneDrive\Documents\GitHub\RoboDanny-rewrite\RoboDanny-rewrite\cogs\stats.py", line 103, in gateway_worker
    await self.notify_gateway_status(record)
  File "C:\Users\billy\OneDrive\Documents\GitHub\RoboDanny-rewrite\RoboDanny-rewrite\cogs\stats.py", line 640, in notify_gateway_status
    await self.webhook.send(msg, username='Gateway', avatar_url='https://i.imgur.com/4PnCKB3.png')
  File "C:\Users\billy\AppData\Roaming\Python\Python38\site-packages\discord\utils.py", line 55, in __get__
    value = self.function(instance)
  File "C:\Users\billy\OneDrive\Documents\GitHub\RoboDanny-rewrite\RoboDanny-rewrite\cogs\stats.py", line 142, in webhook
    wh_id, wh_token = self.bot.config.stat_webhook
AttributeError: module 'config' has no attribute 'stat_webhook'

Database structure

Can you explain how database structure works in the code especially migrations deeply? Thank you.

getting when doing `python launcher.py db init`

could not create PostgreSQL connection pool.
Traceback (most recent call last):
  File "launcher.py", line 100, in init
    run(Table.create_pool(config.postgresql))
  File "D:\program files\python3.8.6\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "C:\Users\adity\Documents\GitHub\RoboDanny\cogs\utils\db.py", line 511, in create_pool
    cls._pool = pool = await asyncpg.create_pool(uri, init=init, **kwargs)
  File "C:\Users\adity\AppData\Roaming\Python\Python38\site-packages\asyncpg\pool.py", line 398, in _async__init__
    await self._initialize()
  File "C:\Users\adity\AppData\Roaming\Python\Python38\site-packages\asyncpg\pool.py", line 426, in _initialize
    await first_ch.connect()
  File "C:\Users\adity\AppData\Roaming\Python\Python38\site-packages\asyncpg\pool.py", line 125, in connect
    self._con = await self._pool._get_new_connection()
  File "C:\Users\adity\AppData\Roaming\Python\Python38\site-packages\asyncpg\pool.py", line 468, in _get_new_connection
    con = await connection.connect(
  File "C:\Users\adity\AppData\Roaming\Python\Python38\site-packages\asyncpg\connection.py", line 1718, in connect
    return await connect_utils._connect(
  File "C:\Users\adity\AppData\Roaming\Python\Python38\site-packages\asyncpg\connect_utils.py", line 674, in _connect
    raise last_error
  File "C:\Users\adity\AppData\Roaming\Python\Python38\site-packages\asyncpg\connect_utils.py", line 663, in _connect
    con = await _connect_addr(
  File "C:\Users\adity\AppData\Roaming\Python\Python38\site-packages\asyncpg\connect_utils.py", line 632, in _connect_addr
    tr, pr = await asyncio.wait_for(
  File "D:\program files\python3.8.6\lib\asyncio\tasks.py", line 491, in wait_for
    return fut.result()
  File "D:\program files\python3.8.6\lib\asyncio\base_events.py", line 986, in create_connection
    infos = await self._ensure_resolved(
  File "D:\program files\python3.8.6\lib\asyncio\base_events.py", line 1365, in _ensure_resolved
    return await loop.getaddrinfo(host, port, family=family, type=type,
  File "D:\program files\python3.8.6\lib\asyncio\base_events.py", line 825, in getaddrinfo
    return await self.run_in_executor(
  File "D:\program files\python3.8.6\lib\concurrent\futures\thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "D:\program files\python3.8.6\lib\socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed

?rtfm does not find exact matches

I believe it's because of the use of dispname being used but it requires some investigating.

e.g. ?rtfm Message.channel or ?rtfm Context.channel

R. danny command suggestion

i think you should add ?tag resources as a default command because it is a very useful command for newbies and add dpy resources on to it.

Why did you make custom reference?

Isn't ctx.message.reference a thing?
Can't you just pass that into like rtfm rather than making a custom one?
or is there a reason why you still make a custom one?

Migrating join-logs didn't work

After the bot was updated a few days ago, it asked to migrate the join-logs in our server using the migrate button. As requested, I gave the bot manage webhooks permission on the channel and role. It successfully created the webhook (and said migration was successful), but did not start sending join-logs to the channel.

I've now enabled it again using /robomod joins, which created a second webhook for the same channel:

image

remind: midnight is always in the past

?remind midnight yadda yadda yadda defaults to 12:00 AM of the current day, which is always in the past. The same can be said of any other time mentioned that, in UTC, is in the past. Therefore I request that if a time is specified but not a day, the reminder should be set for the next occurrence of the specified time.

asyncpg.exceptions.UndefinedTableError: relation "tags" does not exist

When I run the database setup and any commands related to tags, I'm given this error:
In tag make: File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/root/RoboDanny/cogs/tags.py", line 421, in make row = await ctx.db.fetchrow(query, ctx.guild.id, name.lower()) File "/usr/local/lib/python3.8/dist-packages/asyncpg/connection.py", line 641, in fetchrow data = await self._execute( File "/usr/local/lib/python3.8/dist-packages/asyncpg/connection.py", line 1625, in _execute result, _ = await self.__execute( File "/usr/local/lib/python3.8/dist-packages/asyncpg/connection.py", line 1650, in __execute return await self._do_execute( File "/usr/local/lib/python3.8/dist-packages/asyncpg/connection.py", line 1685, in _do_execute stmt = await self._get_statement( File "/usr/local/lib/python3.8/dist-packages/asyncpg/connection.py", line 375, in _get_statement statement = await self._protocol.prepare( File "asyncpg/protocol/protocol.pyx", line 168, in prepare UndefinedTableError: relation "tags" does not exist

Profiles do not support X rank

X rank was added in splatoon 2. The highest S+ rank is now S+9, and in addition, X is a valid rank. Everyone who used to be S+10 or above has been automatically set to X rank.

R. Danny still accepts S+ ranks at or past 10, and does not accept "X" as a valid rank.

Starboard's Jump option isn't always accurate.

When I clicked jump on the Starboard this morning, the bot took me quite a bit above where the actual message was. I kept trying over & over again. I got inconsistent results, but most time, the jump was a bit off mark. It happened in the discord.py server. I have a pic of which one had the error.
Capture

Still having issues getting the bot to work

#126

I fixed the issues that pip caused now I get this
Could not load cogs.meta. Traceback (most recent call last): File "launcher.py", line 112, in init importlib.import_module(ext) File "C:\Users\super\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 783, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "C:\Users\super\Desktop\RoboDanny\Rdanny\RoboDanny\cogs\meta.py", line 2, in <module> from .utils import checks, formats, time File "C:\Users\super\Desktop\RoboDanny\Rdanny\RoboDanny\cogs\utils\time.py", line 3, in <module> from dateutil.relativedelta import relativedelta ValueError: source code string cannot contain null bytes which has nothing to do with pip (I think)

!translate issue

running !translate {anything} returns An error occurred: AttributeError: 'NoneType' object has no attribute 'group'

add role when user add reaction in rewrite version

async def on_raw_reaction_add(self, payload):
    channel = discord.utils.get(self.guild.text_channels, name='★verify-for-chatting★')
    if not payload.guild_id:
        return

    if payload.channel_id != channel.id:
        return	

    guild = self.get_guild(payload.guild_id)
    member = guild.get_member(payload.user_id)

    if payload.emoji.id != 418966077763223552:
        role = discord.utils.get(guild.roles, name="Verified")
    else:
        return

    await member.add_roles(role, reason='Reaction role')
    await member.send(f'You got verified in {self.guild.name}')
    
async def on_raw_reaction_remove(self, payload):
    channel = discord.utils.get(self.guild.text_channels, name='★verify-for-chatting★')
    if not payload.guild_id:
        return

    if payload.channel_id != channel.id:
        return	

    guild = self.get_guild(payload.guild_id)
    member = guild.get_member(payload.user_id)

    if payload.emoji.id != 418966077763223552:
        role = discord.utils.get(guild.roles, name="Verified")
    else:
        return

    await member.remove_roles(role, reason='Reaction role')
    await member.send(f'You got unverified in {self.guild.name}')

So basically I am using this code but it is working in my server and when I am trying to use it in another server where my bot is then it doesn't works and not showing me any error in console

ClientPayloadError: Response payload is not completed

There is an error in cpp command ( module : Lounge<C++>)

In cpp:
  File "C:\Users\billy\AppData\Roaming\Python\Python38\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\billy\OneDrive\Documents\GitHub\RoboDanny-rewrite\RoboDanny-rewrite\cogs\lounge.py", line 214, in cpp
    root = etree.fromstring(await resp.text(), etree.HTMLParser())
  File "C:\Users\billy\AppData\Roaming\Python\Python38\site-packages\aiohttp\client_reqrep.py", line 1009, in text
    await self.read()
  File "C:\Users\billy\AppData\Roaming\Python\Python38\site-packages\aiohttp\client_reqrep.py", line 973, in read
    self._body = await self.content.read()
  File "C:\Users\billy\AppData\Roaming\Python\Python38\site-packages\aiohttp\streams.py", line 358, in read
    block = await self.readany()
  File "C:\Users\billy\AppData\Roaming\Python\Python38\site-packages\aiohttp\streams.py", line 380, in readany
    await self._wait('readany')
  File "C:\Users\billy\AppData\Roaming\Python\Python38\site-packages\aiohttp\streams.py", line 296, in _wait
    await waiter
ClientPayloadError: Response payload is not completed

Ran into problem

2020-06-28 23:33:06] [ERROR ] root: Could not set up PostgreSQL. Exiting.
Traceback (most recent call last):
File "launcher.py", line 53, in run_bot
pool = loop.run_until_complete(Table.create_pool(config.postgresql, command_timeout=60))
File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/root/RoboDanny/cogs/utils/db.py", line 529, in create_pool
cls.pool = pool = await asyncpg.create_pool(uri, init=init, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/asyncpg/pool.py", line 398, in async__init

await self._initialize()
File "/usr/local/lib/python3.8/dist-packages/asyncpg/pool.py", line 426, in _initialize
await first_ch.connect()
File "/usr/local/lib/python3.8/dist-packages/asyncpg/pool.py", line 125, in connect
self._con = await self._pool._get_new_connection()
File "/usr/local/lib/python3.8/dist-packages/asyncpg/pool.py", line 468, in _get_new_connection
con = await connection.connect(
File "/usr/local/lib/python3.8/dist-packages/asyncpg/connection.py", line 1668, in connect
return await connect_utils._connect(
File "/usr/local/lib/python3.8/dist-packages/asyncpg/connect_utils.py", line 663, in _connect
raise last_error
File "/usr/local/lib/python3.8/dist-packages/asyncpg/connect_utils.py", line 652, in _connect
con = await _connect_addr(
File "/usr/local/lib/python3.8/dist-packages/asyncpg/connect_utils.py", line 621, in _connect_addr
tr, pr = await asyncio.wait_for(
File "/usr/lib/python3.8/asyncio/tasks.py", line 483, in wait_for
return fut.result()
File "/usr/lib/python3.8/asyncio/base_events.py", line 986, in create_connection
infos = await self._ensure_resolved(
File "/usr/lib/python3.8/asyncio/base_events.py", line 1365, in _ensure_resolved
return await loop.getaddrinfo(host, port, family=family, type=type,
File "/usr/lib/python3.8/asyncio/base_events.py", line 825, in getaddrinfo
return await self.run_in_executor(
File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

Export tags

Hello!

Awhile back, members of The Coding Den asked for a way to export tags. This was implemented through ?tag all --text, which uploads a parsable file containing the output of a SELECT query. However, I noticed that this doesn't include the content of the tags, meaning we can't export them directly to another bot, or to a JSON file. Is there a roadblock that's stopping this from happening?

Reserve tags during ?tag make

EnterNewName Today at 17:12
When you are in the process of ?tag make, could you make it to where users dont instantly steal your tags

?source could point to invalid branch

In the code for ?source, I have just realized that using the command on a built-in command could point to the discord.py rewrite branch, which was deleted recently.

Auto remove self-stars if possible

Self-stars are annoying and have a psychological effect on causing stars to be added to an otherwise unfunny or uninteresting post. The bot should auto-remove these self-star reactions if it has permission to do so.

Chances are this could also be a setting so people can opt-out of.

A small enhancement to the token detection and GitHub-gist upload system

Currently when R.Danny detects a token in a message it creates a new gist, from which Discord can detect the token
But what if instead of creating a new gist it just edited the same gist over and over again so Discord could read from that?
That would be a lot cleaner, and maybe in the future you could create gists without them getting overcrowded by token gists

eval not work

info discord.py

- Python v3.9.2-final
- discord.py v2.1.0-alpha
    - discord.py pkg_resources: v2.1.0a4542+g59677c67
- aiohttp v3.8.1
- system info: Linux 5.15.32-v8+ #1538 SMP PREEMPT Thu Mar 31 19:40:39 BST 2022

image

Tag command not working

When I try to run ?tag cpp, it gives the following error:

Traceback (most recent call last):
  File "C:\Users\[censored]\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\[censored]\RoboDanny\cogs\tags.py", line 318, in tag
    tag = await self.get_tag(ctx.guild.id, name, connection=ctx.db)
  File "C:\Users\[censored]\RoboDanny\cogs\tags.py", line 241, in get_tag
    row = await con.fetchrow(query, guild_id, name)
  File "C:\Users\[censored]\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\pool.py", line 579, in fetchrow
    return await con.fetchrow(query, *args, timeout=timeout)
  File "C:\Users\[censored]\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\connection.py", line 641, in fetchrow
    data = await self._execute(
  File "C:\Users\[censored]\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\connection.py", line 1625, in _execute
    result, _ = await self.__execute(
  File "C:\Users\[censored]\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\connection.py", line 1650, in __execute
    return await self._do_execute(
  File "C:\Users\[censored]\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\connection.py", line 1685, in _do_execute
    stmt = await self._get_statement(
  File "C:\Users\[censored]\AppData\Local\Programs\Python\Python39\lib\site-packages\asyncpg\connection.py", line 375, in _get_statement
    statement = await self._protocol.prepare(
  File "asyncpg\protocol\protocol.pyx", line 166, in prepare
asyncpg.exceptions.UndefinedTableError: relation "tag_lookup" does not exist

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.