-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgiveaways.py
85 lines (63 loc) · 2.86 KB
/
giveaways.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# █▀▀ ▄▀█ █▀▄▀█ █▀█ █▀▄ █▀
# █▀░ █▀█ █░▀░█ █▄█ █▄▀ ▄█
# https://t.me/famods
# 🔒 Licensed under the GNU AGPLv3
# 🌐 https://www.gnu.org/licenses/agpl-3.0.html
# ---------------------------------------------------------------------------------
# Name: Giveaways
# Description: Авто-участие в розыгрышах Telegram Premium (Hikka 1.6.4+)
# meta developer: @FAmods
# meta banner: https://github.com/FajoX1/FAmods/blob/main/assets/banners/giveaways.png?raw=true
# scope: hikka_min 1.6.4
# ---------------------------------------------------------------------------------
import asyncio
import logging
from telethon.tl.types import MessageMediaGiveaway
from .. import loader, utils
from telethon.tl.functions.channels import JoinChannelRequest
logger = logging.getLogger(__name__)
@loader.tds
class Giveaways(loader.Module):
"""Авто-участие в розыгрышах Telegram Premium"""
strings = {
"name": "Giveaways",
"giveaways_on": "<b><emoji document_id=5852779353330421386>🎁</emoji> Авто-участие включено!</b>",
"giveaways_off": "<b><emoji document_id=5854929766146118183>🚫</emoji> Авто-участие выключено!</b>",
}
def __init__(self):
self.config = loader.ModuleConfig(
loader.ConfigValue(
"log",
True,
lambda: "Писать в логи о участии в новом розыгрыше",
validator=loader.validators.Boolean()
)
)
async def client_ready(self, client, db):
self.db = db
self._client = client
@loader.command()
async def gwtg(self, message):
"""Включить/выключить автоматическое участие в розыгрышах Telegram Premium"""
if self.db.get(self.name, "giveaways_status", False):
self.db.set(self.name, "giveaways_status", False)
return await utils.answer(message, self.strings["giveaways_off"])
self.db.set(self.name, "giveaways_status", True)
await utils.answer(message, self.strings["giveaways_on"])
async def watcher(self, event):
try:
if not isinstance(event.media, MessageMediaGiveaway):
return
except:
return
if not self.db.get(self.name, "giveaways_status"):
return
for c_id in event.media.channels:
try:
channel = await self.client.get_entity(c_id)
await self.client(JoinChannelRequest(channel))
await asyncio.sleep(2.343982493248932)
except:
return
if self.config['log']:
logging.info("Joined to new giveaway")