ytturi / mortdegana_bot Goto Github PK
View Code? Open in Web Editor NEWBot for Fun
License: MIT License
Bot for Fun
License: MIT License
Following #39 ,
The bot will collect user data (username and group_id), when the database is used.
This should be easily accesible by any user using the bot (i.e. /help) and have an opt-in capability instead of working by default when the database is set on bot-level.
The way to do this would be to have an "allowed groups" table in the database and an /opt-in
command (or similar).
When the bot enters the group, send a message informing of its usage.
Add types to all signatures.
Also add a typing test using mypy in our travis CI.
Only running mypy bot.py
should be good enough
Currently we use keywords to search for gifs in giphy (see https://github.com/ytturi/MortDeGana_Bot/blob/master/meldebot/mel/gif.py#L24)
Add other options to get gifs from, like Tenor Gifs or Gfycat. Other providers are also welcomed, however we may need a token to retrieve the gifs using the API, so please share the documentation on how to do so.
The idea is to add new methods in the same file to get the gif from those pages. The signature should be:
get_gif_url_giphy(keywords: List[str]) -> str
get_gif_url_tenor(keywords: List[str]) -> str
get_gif_url_gfycat(keywords: List[str]) -> str
Finally, update the current method (get_gif_url
) to randomly use the provider-specific methods.
We have a list of excuses in meldebot/mel/poll.py
as MOTO_QUOTE
.
We'd like to move them to their own file: excuses.py
, that will act just like insults.py
.
Currently we have checks.sh
to perform some style reformatting (via black
and isort
). It would be nice to configure a more standard way of working like using a pre-commit
hook.
From suggestion in #51 (comment)
Move excuses from poll.py
to its own module (as we have for insults). Then use it in poll handler.
There's something wrong with the excuses as sometimes two of them are prompted into one:
Justament aquest dia he quedat per jugar a arrancar cebesM'he endescuidat de regar el cactus de gisce
Check what insult
does, and add a new reply_text
call whenever we handle a moto
event in the poll handler
Add a new command /help
in order to show a small description about the bot and the link to the repo.
Add a CI task (.travis.yml
) to validate that files are formatted as they should.
An easy way to do this is by running black --check
Show and describe properly the (enabled/finished) commands in the bot.
Also update the ones that are already described.
Add excuses:
Method: https://github.com/ytturi/MortDeGana_Bot/blob/master/meldebot/mel/poll.py#L59
moto_quote_set
as a global in the file (MOTO_QUOTE
)Additional choices:
Mhe endescuidat de regar el cactus de gisce
Mha semblat veure una gota a la carretera
El metge m'ha dit que no puc menjar aliments rics en sodi
Demà haig d'anar a passar la itv
Tinc el rellotge en format 24h
Volia venir pro no soc 1000itar
Volia venir pro no soc 100tifiko
Esque em guardo dies de vacances
Estic esperant la corda i tamboret que m'he demanat a amazon
No puc venir pk la dona m'ha dit que anes a la platja de palafrugell i em quedés un parell d'hores sota l'aigua
Use choice
instead of randint
when getting a random value from lists.
An example can be found here: https://github.com/ytturi/MortDeGana_Bot/blob/master/meldebot/mel/gif.py#L52
We want it to look like: https://github.com/ytturi/MortDeGana_Bot/blob/master/meldebot/mel/poll.py#L65
Requires #54
Right now the /spoiler
action only removes the original message.
After we have the table, it should also store the text from the message.
Then reply with the message: f'@{username} that's a spoiler!
with a button Show spoiler
that will reveal the content.
See the current implementation of /spoiler
to know how to handle the pop-up and the button.
We need a metrics handler, tbd the final provider, probably to be sent to influxDB.
For now, we want a new file within mel
called metrics.py
that we will use for all the metrics functionallities.
In this file we will prepare the metrics according to the parameters, some from the context, and some will have defaults.
I am thinking on something like:
generate_metric(data: List[Tuple[str,Union[int,float]]], send_datetime: datetime = datetime.now()) -> str
data
contains the actual metric. It could be:[('count', 1), ('group_id', 123456)]
The expected output will follow the format:
<timestamp> <data>
Where data has the following format:
identifier0=value0,identifier1=value1...
With the previous values:
"12345678 count=1,group_id=123456"
Aside from that we will also need some data in order to store the metrics using the ChatID and the TelegramUser, those are extracted from the Context. We would like both methods in the utils.py
get_telegram_group_id(context: CallbackContext) -> int
get_telegram_user_id(context: CallbackContext) -> int
Yield a random excuse of the set used when replying moto
to the poll (meldebot/mel/poll.py
as MOTO_QUOTE
)
> /spoiler@meldebot
on reply to a message
<@author of marked message>
that's a spoiler!"#0 A> message: Dumbledore dies!
#1 B> reply to #0: "/spoiler@meldebot"
meldebot> remove #0
meldebot> remove #1
#4 meldebot> message: "@A that's a spoiler! [Show spoiler]"
#5 B> click on "Show spoiler" < "Dumbledore dies!"
Currently, when using motos_ranking
we query all the rows, however, we only need the first 3 or 5.
We would like to limit the results unless the caller is an admin
New excuses:
Casum l'olla! Ja tinc un dinar...
He quedat per fer una muntanya
Jo vindira pero es que se m'ha espatllat el GPS del mòbil
No puc venir que he d'afegir excuses de moto al bot
Add to the existing list in: https://github.com/ytturi/MortDeGana_Bot/blob/master/meldebot/mel/poll.py#L31
Remove tagging users when the motos_ranking
command is called unless the caller is an admin of the group
Following #14
Add gfycat as a gif provider.
We will need a bit of investigation on how to get the access token. Then implement the proper request to search and retrieve the gif url.
A method must be added to the gif provider list (see https://github.com/ytturi/MortDeGana_Bot/blob/master/meldebot/mel/gif.py#L139)
Expected method:
def get_gif_url_gfycat(keywords: List[str]) -> str
Our polls have essentially 2 options: A or B. mel
or moto
.
The polls are message, meaning that they can be identified by:
message.chat
message.date
I think we can store it as an InfluxDB measurement.
In order to do so, we need:
For now, the table would contain:
column name | column type |
---|---|
id | bigint |
group_id | bigint |
message | str |
This needs to be added to database.py
as well as providing a migration script to create the table in the database.
Right now we allow more than one GIF provider (See GIF_PROVIDERS
in gif.py
).
We would like to setup some security around the code and allow setting up only some (or none) of the providers for the bot to work.
The easier way to implement this would be a get_available_providers
method that checks which providers are available based on the configuration values and then creates the available subset of GIF_PROVIDERS
Add an optional parameter to the insult
handler so that we can target them.
Basically we want to append all the text that is provided to the handler before the replied text:
# When extra text is provided
f'{extra_text}, ets un {insult}'
# Otherwise
f'Ets un {insult}'
We need a connector to an InfluxDB instance for the bot.
In order to do so, we need to:
Please check the snippets available at InfluxDB
When this is solved we should be able to:
Add an import sorting call to checks.sh
so that the imports are "automatically" sorted.
An option could be to make use of isort
.
Whatever you choose, make sure it works with black
.
I'd like to get the format:
from X import x
from XY import x, y
from xxxxxxxxxxxxxxxxxxxxxxxxxxx import (
a,
b,
c,
...
)
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.