Created
January 22, 2020 12:33
-
-
Save x0x8x/243e23ccae8363e5340b4bee6d5eedf0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# c = Filters.create(lambda _, cbq: bool(re.match(r"^data_", cbq.callback_data))) | |
# Filters.regex('off-?topic') | |
# @client.on(NewMessage(..., pattern=r'(kek)')) | |
# def handler(event): | |
# event.pattern_match.group(1) | |
# Filters.regex(f'^!({")|(".join(cmd)})') | |
# args = message.text[length(message.matches[0].group(1)):] | |
# '\w*\[.+\]\(.+\)\w*' | |
@Client.on_message( | |
Filters.incoming | |
& Filters.private | |
& Filters.command( | |
["fetch", "fetch@alltaggerbot"], prefixes=["/"], case_sensitive=True | |
) | |
& Filters.regex("(\w+)\s+(.*)") | |
) | |
# @decorators.catch_exceptions() | |
def on_fetch(client: Client, message: Message, args): | |
m = message | |
bot = c = cl = app = client | |
csm = bot.send_message | |
mcid = message.chat.id | |
group = compile(r"\/fetch\s+(.*)") | |
matches = group.finditer(message.text, MULTILINE | IGNORECASE) | |
new_txt: str = message.text | |
for match in matches: | |
new_txt = new_txt.replace(message.matches[0].group(0)) | |
message.reply_chat_action("playing") | |
members = [] | |
# matches = self.no_mention_pattern.finditer(msg.text, MULTILINE | IGNORECASE) | |
# new_txt: str = msg.text | |
# for match in matches: | |
# repl = "" | |
# if match.group(1) == "no_mention": | |
# if match.group(2) == "userid": | |
# repl = match.group(3) | |
# new_txt = new_txt.replace(match.group(0)) | |
# src = re.match(r"fetch\((.+?)\)") | |
# src = re.match(r'(.*)') | |
# matches = group.finditer(message.text, MULTILINE | IGNORECASE) | |
# new_txt: str = message.text | |
# for match in matches: | |
# repl = "" | |
# if match.group(1) == "group": | |
# repl = match.group(2) | |
# new_txt = new_txt.replace(match.group(2)) | |
# if re.match("(?i)(.*)", message.text): | |
chunk_size = 45 | |
for member in list(c.iter_chat_members(*args)): | |
if not member.user.is_bot and not member.user.is_deleted: | |
members.append(member) | |
for i in range(0, len(members), chunk_size): | |
try: | |
csm( | |
mcid, | |
", ".join( | |
[ | |
"[{}](tg://user?id={})".format( | |
i.user.first_name or i.user.username, i.user.id | |
) | |
for i in members[i : i + chunk_size] | |
] | |
), | |
) | |
sleep(0.6) | |
except FloodWait as e: | |
print(f"Cooldown of {e.x} seconds") | |
sleep(e.x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment