-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathmain.py
executable file
·40 lines (29 loc) · 1.14 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from pyrogram import Client, filters
from datetime import datetime
import config
from sql import SQL
app = Client('bot_python', config.api_id, config.api_hash)
bd = SQL('bd.db')
@app.on_message(filters.chat(bd.get_donor()))
def get_post(client, message):
username = message.chat.username
message_id = message.message_id
if not bd.message_id_exists(username, message_id):
bd.add_message_id(username, message_id)
# получение последнего ROWID
for a in bd.get_last_rowid():
last_id = a[0]
# перессылка поста на модерку
message.forward(bd.get_moder(), as_copy=True)
client.send_message(bd.get_moder(), last_id)
@app.on_message(filters.chat(bd.get_moder()))
def send_post(client, message):
# получаем запись в таблице
for item in bd.get_data_in_table(message):
username = item[0]
msg_id = item[1]
send = app.get_messages(username, msg_id)
send.forward(bd.get_channel(), as_copy=True)
if __name__ == '__main__':
print(datetime.today().strftime(f'%H:%M:%S | Bot launched.'))
app.run()