Coder Social home page Coder Social logo

vldc-bot's People

Contributors

alexandersutul avatar c-pro avatar dependabot[bot] avatar dmitryplyaskin avatar egregors avatar elgohr avatar emp7yhead avatar getjump avatar grawl avatar korenskoy avatar lamak avatar moonbasedelta avatar ticketsvl avatar zemlya25 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

Watchers

 avatar  avatar  avatar

vldc-bot's Issues

Add quick bot-checker for new members

  • Detect new users in the chat
  • Send the message with a mention for each new user and ask for a replay
  • Wait for the answer
  • Ban user if bot will not get a reply
  • Post some funny stuff
  • Post a message with a ban confirming

Plus:

  • move all globals into config
  • refactoring
  • move filters to external file
  • update readme (put more vldc stuff)
  • rename repo to vldc_bot
  • replace smile_bot by vldc_bot in the VLDC chat

The main problem right meaw than once kicked user can't retry to join the chat.

Add since-mode

since-mode is counting and showing numbers of days since last mentation of our favorite themes.

It may be two option probably: catch themes buzz words in the messages, or use /since_ command.

For example:

user: ну вообще, ООП решает эту проблему
vldc_bot: This is are 0 days since ООП discussion

or

user: современный php – не такой плохой язык, им вполне можно пользоваться
user2: /since_php
vldc_bot: This is are 2 days since Современный ПеХеПе discussion

For these two options, we need the preselected list of our favorite themes.
Alternativly, we may allow users creating they owns since-words, like:

user: да макось вообще не позволяет ничего кастомизировать, толи дело арч
user2: /since бест ОС евер
vldc_bot: This is are 0 days since бест ОС евер discussion

В таком случае можно добавить вывод всех since за все время:

user: /since_all
vldc_bot:
ООП: 0 days
Современный ПеХеПе: 20 days
бест ОС евер: 2 days

Obviously, we need some persistent storage for this kind of stuff. Let's say it will be mongo

  • add skill
  • add adapter for persistent storage
    • add compose to run bot + storage
    • add .env file for configuration compose (token, chat name, mongo stuff)
    • add mongo into compose (everything become better with mongo)
    • add mongo driver to requirements
    • some way to backups? neh
  • update docs | readme | cmd info in the come skill
  • since cmd
  • since_all cmd

Add link to AoC vldc leaderboard

X-Mas is so near! The current leaderboard created by @C-Pro link: https://adventofcode.com/2019/leaderboard/private/view/458538

I believe bot should post it for /tree command

Add simple ping-mode

Just reply pong for ping command, and remove both messages after a few seconds.

To be sure bot is up

Add /still command for increase irony

u1: да там надо шоткат из 12 кнопок добавить и все будет работать
u2: /still вим настраивать
bot: Вот бы сейчас вим настраивать в 2k19 LULW

Add zero-tolerance blacklist-mode

Add the list of strong \ abusive words to immediately removing msg with them. For example:

user: доброго времени суток, коллеги
vldc_bot: коллеги? no way!
# remove the msg
  • add skill
  • update docs and core skill description
  • appruve black-list

Rewrite bot in Rust

Why choose Python for literally anything in 2k19? It's slow, unsafe, have poor ergonomics and just not good enough for modern development.

Have you heard about Rust? Rust is a statically typed language with strong safety guarantees, native performance and zero-overhead abstractions. It's super-duper cool, makes your code bugs-free and super fast. For free! And it's super popular and will bring you tens and hundreds of new contributors!

Add mode_on \ mode_off decorator

Every mode should have modeName_on and modeName_off handlers, to change the state of mode by admins, without restart container.

It should be decorator for add_MODENAME_handlers.

Add russian translation for bots messages

Need to duplicate all bots messages in two languages. For some reasons, someone from the chat believes it will be a good option for a chat in Russian, idk. And, maybe new users will read bots messages more carefully.

VLDC Code of Conduct

@C-Pro I believe you know much more about this.

  • main points
    • ru
    • en
  • md
  • raw txt for posting CoC by bot on demand (or I may just post the link to GitHub page with CoC)

elegram.error.BadRequest: Message to delete not found

bot_1    | 2019-10-29 16:04:26,084 - telegram.utils.promise - ERROR - An uncaught error was raised while running the promise
bot_1    | Traceback (most recent call last):
bot_1    |   File "/usr/local/lib/python3.7/site-packages/python_telegram_bot-12.0.0b1-py3.7.egg/telegram/utils/promise.py", line 57, in run
bot_1    |     self._result = self.pooled_function(*self.args, **self.kwargs)
bot_1    |   File "/app/bot/skills/towel_mode.py", line 179, in ban_user
bot_1    |     _delete_user_rel_messages(chat_id, user["_id"], context)
bot_1    |   File "/app/bot/skills/towel_mode.py", line 68, in _delete_user_rel_messages
bot_1    |     context.bot.delete_message(chat_id, msg_id)
bot_1    |   File "/usr/local/lib/python3.7/site-packages/python_telegram_bot-12.0.0b1-py3.7.egg/telegram/bot.py", line 66, in decorator
bot_1    |     result = func(self, *args, **kwargs)
bot_1    |   File "/usr/local/lib/python3.7/site-packages/python_telegram_bot-12.0.0b1-py3.7.egg/telegram/bot.py", line 292, in delete_message
bot_1    |     result = self._request.post(url, data, timeout=timeout)
bot_1    |   File "/usr/local/lib/python3.7/site-packages/python_telegram_bot-12.0.0b1-py3.7.egg/telegram/utils/request.py", line 327, in post
bot_1    |     **urlopen_kwargs)
bot_1    |   File "/usr/local/lib/python3.7/site-packages/python_telegram_bot-12.0.0b1-py3.7.egg/telegram/utils/request.py", line 238, in _request_wrapper
bot_1    |     raise BadRequest(message)
bot_1    | telegram.error.BadRequest: Message to delete not found

SinceMode should be completely reworked, now it is just flood generator

I believe it should be a custom Tg keyboard with all subjects as buttons.
User may use /since cmd, and then only this user will see the keyboard, and make a choice, wich one subject must be updated.

Only admins can add subjects. Let's say by /since_add cmd.

And we need some anti-flood protection I guess.

Sometime message is None

bot_1    | 2019-09-24 00:05:56,590 - skills.since_mode - INFO - topic from db for title I been gone is None
bot_1    | 2019-09-24 00:05:56,590 - telegram.ext.dispatcher - ERROR - An uncaught error was raised while processing the update
bot_1    | Traceback (most recent call last):
bot_1    |   File "/usr/local/lib/python3.7/site-packages/python_telegram_bot-12.0.0b1-py3.7.egg/telegram/ext/dispatcher.py", line 333, in process_update
bot_1    |     handler.handle_update(update, self, check, context)
bot_1    |   File "/usr/local/lib/python3.7/site-packages/python_telegram_bot-12.0.0b1-py3.7.egg/telegram/ext/handler.py", line 117, in handle_update
bot_1    |     return self.callback(update, context)
bot_1    |   File "/app/bot/skills/since_mode.py", line 79, in since_callback
bot_1    |     update.message.reply_text(
bot_1    | AttributeError: 'NoneType' object has no attribute 'reply_text'

Add event-mode

We need to add /soon, /events and /add_event commands.

For admins: /add_event will add event date, links and short description of the event.

For all:

  • /soon – show info about the soonest event
  • /events – show list of the last N events

As usual:

  • add skill with new skill-group number
  • add description of new command into core skill
  • mongo as storage for events

Add silence mode

Temporarily disable any non-essential features, like /uwu, /still etc., sometimes there's too much junk.

Suggested behaviours:

  • ON/OFF. Like /smile or /since.
  • Countdown. All minor features will be disabled for reasonable amount of time (like 10m or so).

telegram.error.BadRequest: Chat not found

2019-11-08 08:39:55,409 - telegram.utils.promise - ERROR - An uncaught error was raised while running the promise
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/python_telegram_bot-12.0.0b1-py3.7.egg/telegram/utils/promise.py", line 57, in run
    self._result = self.pooled_function(*self.args, **self.kwargs)
  File "/app/bot/skills/towel_mode.py", line 176, in ban_user
    chat_id = context.bot.get_chat(chat_id=context.job.context["chat_id"]).id
  File "/usr/local/lib/python3.7/site-packages/python_telegram_bot-12.0.0b1-py3.7.egg/telegram/bot.py", line 66, in decorator
    result = func(self, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/python_telegram_bot-12.0.0b1-py3.7.egg/telegram/bot.py", line 2159, in get_chat
    result = self._request.post(url, data, timeout=timeout)
  File "/usr/local/lib/python3.7/site-packages/python_telegram_bot-12.0.0b1-py3.7.egg/telegram/utils/request.py", line 327, in post
    **urlopen_kwargs)
  File "/usr/local/lib/python3.7/site-packages/python_telegram_bot-12.0.0b1-py3.7.egg/telegram/utils/request.py", line 238, in _request_wrapper
    raise BadRequest(message)
telegram.error.BadRequest: Chat not found

Add CI for new versions

@C-Pro could you add some automation for deployment each new version?

After each push into master Docker Hub will build the new latest version on the container. And, looks like we may just pull new container, but sometimes we are updating the docker-compose (for adding new services for example), and at this case, we need more smartest deploy.

We may user GitHub Actions for this purpose, I guess. So, I believe it may look like:

  • push to master -> check (stylelints, tests, mypy, etc)
  • DokcerHub build new Image (wait for it)
  • if checks are the green and new image is ready: deploy a new version:

@lamak now it is your horse 🐴

Add "russian roulette" command

Add roll /roll support. This is command for regular users only (not for admins).

u1: /roll
bot: miss!
u2: /roll
bot: miss!
u1: /roll
bot: Boom! Mute for u1 for 24 hours

Note: chance to being shoot is 1/6

Add some fancy CI stuff

Let's use come GitHub actions magic!
What we should add to our quality gate?

build:

  • tests
  • mypy
  • flake8

upd: for now, I'll restart container manually (meh)

Add mute command

Something like /mute @C-Pro 90 for muting (removing all messages) by user @C-Pro during 90 minutes

Topics should be normalized before search


bot_1    | 2019-09-24 05:18:08,146 - skills.since_mode - INFO - topic from db for title 72k is None
bot_1    | 2019-09-24 05:20:34,343 - skills.since_mode - INFO - topic from db for title Баг is None
bot_1    | 2019-09-24 05:20:49,825 - skills.since_mode - INFO - topic from db for title бАг is None
bot_1    | 2019-09-24 05:21:40,150 - skills.since_mode - INFO - topic from db for title Баг is None
bot_1    | 2019-09-24 05:21:44,787 - skills.since_mode - INFO - topic from db for title Баг is None
bot_1    | 2019-09-24 05:21:54,895 - skills.since_mode - INFO - topic from db for title Баг is None

Add "cleanup" decorator

Add "cleanup" decorator for modes and commands.

This decorator should take a number of seconds as a parameter, and provide the removing affected messages (user cmd, bot answers) after a while.

For example:

@cleanup(600)
def add_roll(upd: Updater, handlers_group: int):
    logger.info("registering roll handlers")
    dp = upd.dispatcher
    dp.add_handler(CommandHandler("roll", roll), handlers_group)

should looks in the chat like:

u1: /roll
bot: 💥 boom! u 😵 [8h mute]
u2: лол
u3: кек
u3: чебурек

after 10 minutes messages u1: /roll and bot: 💥 boom! u 😵 [8h mute] should be removed

Remove greeting message after confirming user

If the user presses the button, we don't need to show a greeting message anymore

  • remove greeting message if a new user is answered
  • remove greeting message after 60 minutes if a new user is a bot

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.