This repository has been archived by the owner on Dec 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: NaytSeyd <[email protected]>
- Loading branch information
Showing
6 changed files
with
893 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Copyright (C) 2020 TeamDerUntergang. | ||
# | ||
# SedenUserBot is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# SedenUserBot is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
# @NaytSeyd tarafından portlanmıştır. | ||
# | ||
|
||
import io | ||
import re | ||
import asyncio | ||
|
||
from telethon import events, utils | ||
from telethon.tl import types, functions | ||
|
||
import sedenbot.moduller.sql_helper.blacklist_sql as sql | ||
from sedenbot import CMD_HELP, bot | ||
from sedenbot.events import sedenify | ||
|
||
@sedenify(incoming=True, disable_edited=True, disable_errors=True) | ||
async def on_new_message(event): | ||
name = event.raw_text | ||
snips = sql.get_chat_blacklist(event.chat_id) | ||
for snip in snips: | ||
pattern = r"( |^|[^\w])" + re.escape(snip) + r"( |$|[^\w])" | ||
if re.search(pattern, name, flags=re.IGNORECASE): | ||
try: | ||
await event.delete() | ||
except Exception as e: | ||
await event.reply("I do not have DELETE permission in this chat") | ||
sql.rm_from_blacklist(event.chat_id, snip.lower()) | ||
break | ||
pass | ||
|
||
@sedenify(outgoing=True, pattern="^.addblacklist(?: |$)(.*)") | ||
async def on_add_black_list(addbl): | ||
text = addbl.pattern_match.group(1) | ||
to_blacklist = list(set(trigger.strip() for trigger in text.split("\n") if trigger.strip())) | ||
for trigger in to_blacklist: | ||
sql.add_to_blacklist(addbl.chat_id, trigger.lower()) | ||
await addbl.edit("{} **adet kelime bu sohbet için karalisteye alındı.**".format(len(to_blacklist))) | ||
|
||
@sedenify(outgoing=True, pattern="^.listblacklist(?: |$)(.*)") | ||
async def on_view_blacklist(listbl): | ||
all_blacklisted = sql.get_chat_blacklist(listbl.chat_id) | ||
OUT_STR = "**Bu grup için ayarlanan karaliste:**\n" | ||
if len(all_blacklisted) > 0: | ||
for trigger in all_blacklisted: | ||
OUT_STR += f"`{trigger}`\n" | ||
else: | ||
OUT_STR = "**Karalisteye eklenmiş kelime bulunamadı..** `.addblacklist` **komutu ile ekleyebilirsin.**" | ||
if len(OUT_STR) > 4096: | ||
with io.BytesIO(str.encode(OUT_STR)) as out_file: | ||
out_file.name = "blacklist.text" | ||
await listbl.client.send_file( | ||
listbl.chat_id, | ||
out_file, | ||
force_document=True, | ||
allow_cache=False, | ||
caption="**Bu grup için ayarlanan karaliste:**", | ||
reply_to=listbl | ||
) | ||
await listbl.delete() | ||
else: | ||
await listbl.edit(OUT_STR) | ||
|
||
@sedenify(outgoing=True, pattern="^.rmblacklist(?: |$)(.*)") | ||
async def on_delete_blacklist(rmbl): | ||
text = rmbl.pattern_match.group(1) | ||
to_unblacklist = list(set(trigger.strip() for trigger in text.split("\n") if trigger.strip())) | ||
successful = 0 | ||
for trigger in to_unblacklist: | ||
if sql.rm_from_blacklist(rmbl.chat_id, trigger.lower()): | ||
successful += 1 | ||
await rmbl.edit(f"**Kelime karalisteden kaldırıldı.**") | ||
|
||
CMD_HELP.update({ | ||
"blacklist": | ||
".listblaclist\ | ||
\nKullanım: Bir sohbetteki etkin kara listeyi listeler.\ | ||
\n\n.addblacklist <kelime>\ | ||
\nKullanım: İletiyi 'kara liste anahtar kelimesine' kaydeder.\ | ||
\n'Kara liste anahtar kelimesinden' bahsedildiğinde bot iletiyi siler.\ | ||
\n\n.rmblacklist <kelime>\ | ||
\nKullanım: Belirtilen kara listeyi durdurur.\ | ||
\nBu arada bu işlemleri gerçekleştirmek için yönetici olmalı ve **Mesaj Silme** yetkiniz olmalı." | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
# Copyright (C) 2020 TeamDerUntergang. | ||
# | ||
# SedenUserBot is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# SedenUserBot is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
# @NaytSeyd tarafından portlanmıştır | ||
|
||
from math import sqrt | ||
from emoji import emojize | ||
from datetime import datetime | ||
|
||
from telethon.utils import get_input_location | ||
from telethon.tl.functions.channels import GetFullChannelRequest, GetParticipantsRequest | ||
from telethon.tl.functions.messages import GetHistoryRequest, CheckChatInviteRequest, GetFullChatRequest | ||
from telethon.tl.types import MessageActionChannelMigrateFrom, ChannelParticipantsAdmins | ||
from telethon.errors import (ChannelInvalidError, ChannelPrivateError, ChannelPublicGroupNaError, InviteHashEmptyError, InviteHashExpiredError, InviteHashInvalidError) | ||
|
||
from sedenbot import CMD_HELP | ||
from sedenbot.events import sedenify | ||
|
||
@sedenify(pattern=".chatinfo(?: |$)(.*)", outgoing=True) | ||
async def info(event): | ||
await event.edit("`Grup analiz ediliyor...`") | ||
chat = await get_chatinfo(event) | ||
caption = await fetch_info(chat, event) | ||
try: | ||
await event.edit(caption, parse_mode="html") | ||
except Exception as e: | ||
print("Exception:", e) | ||
await event.edit("`Beklenmeyen bir hata oluştu.`") | ||
return | ||
|
||
async def get_chatinfo(event): | ||
chat = event.pattern_match.group(1) | ||
chat_info = None | ||
if chat: | ||
try: | ||
chat = int(chat) | ||
except ValueError: | ||
pass | ||
if not chat: | ||
if event.reply_to_msg_id: | ||
replied_msg = await event.get_reply_message() | ||
if replied_msg.fwd_from and replied_msg.fwd_from.channel_id is not None: | ||
chat = replied_msg.fwd_from.channel_id | ||
else: | ||
chat = event.chat_id | ||
try: | ||
chat_info = await event.client(GetFullChatRequest(chat)) | ||
except: | ||
try: | ||
chat_info = await event.client(GetFullChannelRequest(chat)) | ||
except ChannelInvalidError: | ||
await event.edit("`Geçersiz kanal/grup`") | ||
return None | ||
except ChannelPrivateError: | ||
await event.edit("`Bu özel bir kanal/grup veya oradan yasaklandım`") | ||
return None | ||
except ChannelPublicGroupNaError: | ||
await event.edit("`Kanal veya süpergrup mevcut değil`") | ||
return None | ||
except (TypeError, ValueError) as err: | ||
await event.edit(str(err)) | ||
return None | ||
return chat_info | ||
|
||
async def fetch_info(chat, event): | ||
chat_obj_info = await event.client.get_entity(chat.full_chat.id) | ||
broadcast = chat_obj_info.broadcast if hasattr(chat_obj_info, "broadcast") else False | ||
chat_type = "Kanal" if broadcast else "Grup" | ||
chat_title = chat_obj_info.title | ||
warn_emoji = emojize(":warning:") | ||
try: | ||
msg_info = await event.client(GetHistoryRequest(peer=chat_obj_info.id, offset_id=0, offset_date=datetime(2010, 1, 1), | ||
add_offset=-1, limit=1, max_id=0, min_id=0, hash=0)) | ||
except Exception as e: | ||
msg_info = None | ||
print("Exception:", e) | ||
first_msg_valid = True if msg_info and msg_info.messages and msg_info.messages[0].id == 1 else False | ||
creator_valid = True if first_msg_valid and msg_info.users else False | ||
creator_id = msg_info.users[0].id if creator_valid else None | ||
creator_firstname = msg_info.users[0].first_name if creator_valid and msg_info.users[0].first_name is not None else "Deleted Account" | ||
creator_username = msg_info.users[0].username if creator_valid and msg_info.users[0].username is not None else None | ||
created = msg_info.messages[0].date if first_msg_valid else None | ||
former_title = msg_info.messages[0].action.title if first_msg_valid and type(msg_info.messages[0].action) is MessageActionChannelMigrateFrom and msg_info.messages[0].action.title != chat_title else None | ||
try: | ||
dc_id, location = get_input_location(chat.full_chat.chat_photo) | ||
except Exception as e: | ||
dc_id = "Unknown" | ||
location = str(e) | ||
|
||
description = chat.full_chat.about | ||
members = chat.full_chat.participants_count if hasattr(chat.full_chat, "participants_count") else chat_obj_info.participants_count | ||
admins = chat.full_chat.admins_count if hasattr(chat.full_chat, "admins_count") else None | ||
banned_users = chat.full_chat.kicked_count if hasattr(chat.full_chat, "kicked_count") else None | ||
restrcited_users = chat.full_chat.banned_count if hasattr(chat.full_chat, "banned_count") else None | ||
members_online = chat.full_chat.online_count if hasattr(chat.full_chat, "online_count") else 0 | ||
group_stickers = chat.full_chat.stickerset.title if hasattr(chat.full_chat, "stickerset") and chat.full_chat.stickerset else None | ||
messages_viewable = msg_info.count if msg_info else None | ||
messages_sent = chat.full_chat.read_inbox_max_id if hasattr(chat.full_chat, "read_inbox_max_id") else None | ||
messages_sent_alt = chat.full_chat.read_outbox_max_id if hasattr(chat.full_chat, "read_outbox_max_id") else None | ||
exp_count = chat.full_chat.pts if hasattr(chat.full_chat, "pts") else None | ||
username = chat_obj_info.username if hasattr(chat_obj_info, "username") else None | ||
bots_list = chat.full_chat.bot_info # this is a list | ||
bots = 0 | ||
supergroup = "<b>Evet</b>" if hasattr(chat_obj_info, "megagroup") and chat_obj_info.megagroup else "Hayır" | ||
slowmode = "<b>Evet</b>" if hasattr(chat_obj_info, "slowmode_enabled") and chat_obj_info.slowmode_enabled else "Hayır" | ||
slowmode_time = chat.full_chat.slowmode_seconds if hasattr(chat_obj_info, "slowmode_enabled") and chat_obj_info.slowmode_enabled else None | ||
restricted = "<b>Evet</b>" if hasattr(chat_obj_info, "restricted") and chat_obj_info.restricted else "Hayır" | ||
verified = "<b>Evet</b>" if hasattr(chat_obj_info, "verified") and chat_obj_info.verified else "Hayır" | ||
username = "@{}".format(username) if username else None | ||
creator_username = "@{}".format(creator_username) if creator_username else None | ||
|
||
if admins is None: | ||
try: | ||
participants_admins = await event.client(GetParticipantsRequest(channel=chat.full_chat.id, filter=ChannelParticipantsAdmins(), | ||
offset=0, limit=0, hash=0)) | ||
admins = participants_admins.count if participants_admins else None | ||
except Exception as e: | ||
print("Exception:", e) | ||
if bots_list: | ||
for bot in bots_list: | ||
bots += 1 | ||
|
||
caption = "<b>GRUP BILGISI:</b>\n" | ||
caption += f"ID: <code>{chat_obj_info.id}</code>\n" | ||
if chat_title is not None: | ||
caption += f"{chat_type} ismi: {chat_title}\n" | ||
if former_title is not None: | ||
caption += f"Eski grup: {former_title}\n" | ||
if username is not None: | ||
caption += f"{chat_type} tipi: Herkese açık\n" | ||
caption += f"Link: {username}\n" | ||
else: | ||
caption += f"{chat_type} tipi: Gizli\n" | ||
if creator_username is not None: | ||
caption += f"Oluşturan kişi: {creator_username}\n" | ||
elif creator_valid: | ||
caption += f"Oluşturan kişi: <a href=\"tg://user?id={creator_id}\">{creator_firstname}</a>\n" | ||
if created is not None: | ||
caption += f"Oluşturulma tarihi: <code>{created.date().strftime('%b %d, %Y')} - {created.time()}</code>\n" | ||
else: | ||
caption += f"Oluşturulma tarihi: <code>{chat_obj_info.date.date().strftime('%b %d, %Y')} - {chat_obj_info.date.time()}</code> {warn_emoji}\n" | ||
caption += f"Veri merkezi ID: {dc_id}\n" | ||
if exp_count is not None: | ||
chat_level = int((1+sqrt(1+7*exp_count/14))/2) | ||
caption += f"{chat_type} seviyesi: <code>{chat_level}</code>\n" | ||
if messages_viewable is not None: | ||
caption += f"Görüntülenebilir mesajlar: <code>{messages_viewable}</code>\n" | ||
if messages_sent: | ||
caption += f"Gönderilen mesajlar: <code>{messages_sent}</code>\n" | ||
elif messages_sent_alt: | ||
caption += f"Gönderilen mesajlar: <code>{messages_sent_alt}</code> {warn_emoji}\n" | ||
if members is not None: | ||
caption += f"Üye sayısı: <code>{members}</code>\n" | ||
if admins is not None: | ||
caption += f"Yönetici sayısı: <code>{admins}</code>\n" | ||
if bots_list: | ||
caption += f"Bot sayısı: <code>{bots}</code>\n" | ||
if members_online: | ||
caption += f"Çevrimiçi kişi sayısı: <code>{members_online}</code>\n" | ||
if restrcited_users is not None: | ||
caption += f"Kısıtlı kullanıcı sayısı: <code>{restrcited_users}</code>\n" | ||
if banned_users is not None: | ||
caption += f"Yasaklanmış kullanıcı sayısı: <code>{banned_users}</code>\n" | ||
if group_stickers is not None: | ||
caption += f"{chat_type} çıkartma paketi: <a href=\"t.me/addstickers/{chat.full_chat.stickerset.short_name}\">{group_stickers}</a>\n" | ||
caption += "\n" | ||
if not broadcast: | ||
caption += f"Yavaş mod: {slowmode}" | ||
if hasattr(chat_obj_info, "slowmode_enabled") and chat_obj_info.slowmode_enabled: | ||
caption += f", <code>{slowmode_time}s</code>\n\n" | ||
else: | ||
caption += "\n\n" | ||
if not broadcast: | ||
caption += f"Süper grup mu: {supergroup}\n\n" | ||
if hasattr(chat_obj_info, "restricted"): | ||
caption += f"Kısıtlı mı: {restricted}\n" | ||
if chat_obj_info.restricted: | ||
caption += f"> Platform: {chat_obj_info.restriction_reason[0].platform}\n" | ||
caption += f"> Nedeni: {chat_obj_info.restriction_reason[0].reason}\n" | ||
caption += f"> Metin: {chat_obj_info.restriction_reason[0].text}\n\n" | ||
else: | ||
caption += "\n" | ||
if hasattr(chat_obj_info, "scam") and chat_obj_info.scam: | ||
caption += "Scam: <b>Evet</b>\n\n" | ||
if hasattr(chat_obj_info, "verified"): | ||
caption += f"Telegram tarafından doğrulandı mı: {verified}\n\n" | ||
if description: | ||
caption += f"Grup açıklaması: \n<code>{description}</code>\n" | ||
return caption | ||
|
||
CMD_HELP.update({ | ||
"chatinfo": | ||
".chatinfo [isteğe bağlı: <grup id/davet linki>] \ | ||
\nKullanım: Bir grup hakkında bilgi alır. Bazı bilgiler eksik izinler nedeniyle sınırlı olabilir." | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Copyright (C) 2020 TeamDerUntergang. | ||
# | ||
# SedenUserBot is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# SedenUserBot is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
# @NaytSeyd tarafından portlanmıştır | ||
# | ||
|
||
import os | ||
|
||
from telethon import events | ||
from PIL import Image, ImageColor | ||
|
||
from sedenbot import CMD_HELP, bot | ||
from sedenbot.events import sedenify | ||
|
||
@sedenify(outgoing=True, pattern="^.color (.*)") | ||
async def _(event): | ||
if event.fwd_from: | ||
return | ||
input_str = event.pattern_match.group(1) | ||
message_id = event.message.id | ||
if event.reply_to_msg_id: | ||
message_id = event.reply_to_msg_id | ||
if input_str.startswith("#"): | ||
try: | ||
usercolor = ImageColor.getrgb(input_str) | ||
except Exception as e: | ||
await event.edit(str(e)) | ||
return False | ||
else: | ||
im = Image.new(mode="RGB", size=(1280, 720), color=usercolor) | ||
im.save("sedencik.png", "PNG") | ||
input_str = input_str.replace("#", "#RENK_") | ||
await bot.send_file( | ||
event.chat_id, | ||
"sedencik.png", | ||
force_document=False, | ||
caption=input_str, | ||
reply_to=message_id | ||
) | ||
os.remove("sedencik.png") | ||
await event.delete() | ||
else: | ||
await event.edit("Belki burayı okuyarak bir şeyler öğrenebilirsin.. \ | ||
`.color <renk kodu>`") | ||
|
||
CMD_HELP.update({ | ||
'color': ".color <renk kodu> \ | ||
\nKullanım: Belirttiğniz renk kodunun çıktısını alın. \ | ||
\nÖrnek: .color #330066" | ||
}) |
Oops, something went wrong.