Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kanewi11 committed Oct 16, 2022
1 parent ca308f9 commit ce025fb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
.idea/**/dictionaries
.idea/**/shelf

sessions/*.session
sessions/*.ini
sessions/*.json
sessions/*
test.py
*.log

Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Bot for posting reactions to a Telegram post.
**Bot puts reactions only to new posts!**

**Sessions must be for Pyrogram!**

## Launch Instructions:
1. `git clone https://github.com/kanewi11/telegram-reaction-bot.git`
2. `python3 -m venv venv`
3. `source venv/bin/activate`
4. `pip install -r requirements.txt`
5. Add your channel name to `config.py`.
6. Add the session file and its configuration file to the `/sessions` directory. **These two files must have the same name!** Here is an example:
```
/sessions
│ 8888888888.ini
│ 8888888888.session
│ 9999999999.ini
│ 9999999999.session
│ 98767242365.json
│ 98767242365.session
```
7. `nohup python reactionbot.py &`
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
channels = ['you_channel_name']
channels = ['werqrewqrqwr']
10 changes: 7 additions & 3 deletions reactionbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
from pathlib import Path

import uvloop
from pyrogram import Client, idle, filters, types
from pyrogram.errors import ReactionInvalid
from pyrogram.handlers import MessageHandler
from pyrogram import Client, idle, filters, types

from config import channels

Expand All @@ -35,13 +36,16 @@
'phone_number': ['phone_number', 'phone']
}

emojis = ['👍', '❤️', '🔥', '🥰', '👏', '😁', '🤔', '🤯', '🎉', '🤩', '⚡️', '💯', '❤️‍🔥', '🙏🏻']
emojis = ['👍', '❤️', '🔥', '🥰', '👏', '😁', '🤔', '🤯', '🎉', '🤩', '⚡️', '💯', '❤️‍🔥']


async def send_reaction(client: Client, message: types.Message) -> None:
"""Хендлер для отправки реакций"""
emoji = random.choice(emojis)
await client.send_reaction(chat_id=message.chat.id, message_id=message.id, emoji=emoji)
try:
await client.send_reaction(chat_id=message.chat.id, message_id=message.id, emoji=emoji)
except ReactionInvalid:
logging.warning(f'{emoji} - INVALID REACTION')


async def make_work_dir() -> None:
Expand Down

0 comments on commit ce025fb

Please sign in to comment.