Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
from telegram import Update
from telegram.ext import Updater, CommandHandler, CallbackContext
import psutil # Import the psutil library for system information
import datetime
import requests
import io
import base64
from telegram.error import Unauthorized
import json
# Komut İmportları
from gsmtc import gsmtc_sorgula
from tcgsm import tcgsm_sorgula
from tcsorgu import tc_sorgula
from adsoyad import adsoyad_sorgula
from yardim import send_help_message
from discord import send_discord_message
from sorgular import send_sorgular_message
from ailesorgu import aile_sorgula
from panel import send_panel_message
import autorespond # Import the autorespond.py script
# Ayarlar
from log import log_action, get_logs, clear_logs
from config import BOT_TOKEN, admin_ids, allowed_channel_id, channel_ids
API_URL = "https://api.hypist.online/vesika?key=free"
def talk_command(update: Update, context: CallbackContext):
user_id = update.effective_user.id
if user_id in admin_ids:
# The user is an admin
if len(context.args) >= 1:
# Extract the message text from the command arguments
message_text = ' '.join(context.args)
try:
for channel_id in channel_ids:
# Send the message to each target channel
context.bot.send_message(chat_id=channel_id, text=message_text)
update.message.reply_text(f"{message_text}")
except Unauthorized:
update.message.reply_text("Botun bu kanala mesaj gönderme yetkisi yok.")
else:
update.message.reply_text("Kullanım: /talk Metin")
else:
update.message.reply_text("Bu komutu kullanmak için yetkiniz bulunmamakta.")
def main():
updater = Updater(token=BOT_TOKEN, use_context=True)
dp = updater.dispatcher
autorespond.setup_autorespond(dp)
def check_channel_membership(update: Update, context: CallbackContext):
user_id = update.effective_user.id
if update.message.chat_id == allowed_channel_id:
# The command was sent in the allowed channel, restrict access
join_channel_message = f"❗️ Sorgu yapabilmek için [Bu Kanala](https://t.me/yunusmarka) katılmanız gerekmektedir"
update.message.reply_markdown(join_channel_message)
return False
if not context.bot.get_chat_member(allowed_channel_id, user_id).status in ['member', 'administrator', 'creator']:
# User is not a member of the allowed channel
join_channel_message = f"❗️ Sorgu yapabilmek için [Bu Kanala](https://t.me/yunusmarka) katılmanız gerekmektedir"
update.message.reply_markdown(join_channel_message)
return False
return True
def start(update: Update, context: CallbackContext):
user_username = update.message.from_user.username
# Handle the /start command
# Count the number of log entries
try:
with open("bot_log.txt", "r") as log_file:
log_entries = log_file.readlines()
sorgu_sayisi = len(log_entries)
except FileNotFoundError:
sorgu_sayisi = 0
start_message = (
f"🕵🏼 Sorgu Botuna Hoşgeldin, @{user_username} 🕵🏼 nn"
"❗ Sorgu yapabilmek için [Bu Kanala](https://t.me/yunusmarka) katılmanız gerekmektedir ❗ nn"
"📕 Sorgu Listesi İçin: '/sorgular' 📕 nn"
"📗 Yardım İçin '/yardim' 📗 nn"
f"🔉 Discord'a katılmak için '/discord' 🔉 nn"
f"Yapılan Sorgu Sayısı: {sorgu_sayisi}"
)
update.message.reply_markdown_v2(start_message)
def vesika_handler(update: Update, context: CallbackContext):
user_id = update.effective_user.id
chat_id = update.message.chat_id # Get the chat ID of the current channel
if chat_id == -1001814036136:
update.message.reply_text("Bu komut bu kanalda kullanılamaz. DM'den Kullanabilirsiniz")
return
# Check if the user is a member of the allowed channel
if not context.bot.get_chat_member(allowed_channel_id, user_id).status in ['member', 'administrator',
'creator']:
# User is not a member of the allowed channel
join_channel_message = f"❗️ Sorgu yapabilmek için [Bu Kanala](https://t.me/yunusmarka) katılmanız gerekmektedir"
update.message.reply_markdown(join_channel_message)
return
# Check if the /vesika command is called with a valid TC parameter
if len(context.args) != 1:
update.message.reply_text("Usage: /vesika TC")
log_action(user_id, "vesika", str(context.args))
return
# Extract the TC from the command
tc = context.args[0]
# Construct the API URL with the provided TC
api_url_with_tc = f"{API_URL}&tc={tc}"
# Send a request to the API
response = requests.get(api_url_with_tc)
if response.status_code == 200:
try:
# Decode the base64 image from the API response
data = response.json()["data"]
image_data = base64.b64decode(data)
# Send the image as a photo
photo_io = io.BytesIO(image_data)
update.message.reply_photo(photo=photo_io)
except Exception as e:
update.message.reply_text("An error occurred while processing the response.")
print(e)
else:
update.message.reply_text("Failed to fetch vesika information. Please try again later.")
def tc_sorgula_handler(update: Update, context: CallbackContext):
user_id = update.effective_user.id
chat_id = update.message.chat_id # Get the chat ID of the current channel
if chat_id == -1001814036136:
update.message.reply_text("Bu komut bu kanalda kullanılamaz. DM'den Kullanabilirsiniz")
return
if check_channel_membership(update, context):
user_id = update.effective_user.id
log_action(user_id, "tc", str(context.args))
tc_sorgula(update, context) # Call the function from tcsorgu.py
def adsoyad_sorgula_handler(update: Update, context: CallbackContext):
user_id = update.effective_user.id
chat_id = update.message.chat_id # Get the chat ID of the current channel
if chat_id == -1001814036136:
update.message.reply_text("Bu komut bu kanalda kullanılamaz. DM'den Kullanabilirsiniz")
return
if check_channel_membership(update, context):
user_id = update.effective_user.id
log_action(user_id, "adsoyad", str(context.args))
adsoyad_sorgula(update, context) # Call the function from adsoyad.py
def gsmtc_sorgula_handler(update: Update, context: CallbackContext):
user_id = update.effective_user.id
chat_id = update.message.chat_id # Get the chat ID of the current channel
if chat_id == -1001814036136:
update.message.reply_text("Bu komut bu kanalda kullanılamaz. DM'den Kullanabilirsiniz")
return
if check_channel_membership(update, context):
user_id = update.effective_user.id
log_action(user_id, "gsmtc", str(context.args))
gsmtc_sorgula(update, context) # GSM -> TC
def tcgsm_sorgula_handler(update: Update, context: CallbackContext):
user_id = update.effective_user.id
chat_id = update.message.chat_id # Get the chat ID of the current channel
if chat_id == -1001814036136:
update.message.reply_text("Bu komut bu kanalda kullanılamaz. DM'den Kullanabilirsiniz")
return
if check_channel_membership(update, context):
user_id = update.effective_user.id
log_action(user_id, "tcgsm", str(context.args))
tcgsm_sorgula(update, context)
def help_command(update: Update, context: CallbackContext):
if check_channel_membership(update, context):
send_help_message(update, context)
def discord_command(update: Update, context: CallbackContext):
if check_channel_membership(update, context):
send_discord_message(update, context)
def sorgular_command(update: Update, context: CallbackContext):
if check_channel_membership(update, context):
send_sorgular_message(update, context)
def panel_command(update: Update, context: CallbackContext):
if check_channel_membership(update, context):
send_panel_message(update, context)
def adres_handler(update: Update, context: CallbackContext):
user_id = update.effective_user.id
chat_id = update.message.chat_id # Get the chat ID of the current channel
if not check_channel_membership(update, context):
return
if len(context.args) != 1:
update.message.reply_text("Kullanım: /adres TC")
log_action(user_id, "adres", str(context.args))
return # Corrected indentation here
tc = context.args[0]
# Construct the API URL with the provided TC
api_url = f"https://api.kyrexpro.com.tr/api/apiadres.php?tc={tc}"
# Send a request to the API
response = requests.get(api_url)
if response.status_code == 200:
try:
# Parse the JSON response
data = response.json()
adres = data.get("adres", "")
vergino = data.get("vergino", "")
vergidairekodu = data.get("vergidairekodu", "")
# Create a response message with the extracted values
response_message = (
f"Adres: {adres}n"
f"Vergi No: {vergino}n"
f"Vergi Dairesi Kodu: {vergidairekodu}"
)
update.message.reply_text(response_message)
except json.JSONDecodeError:
update.message.reply_text("API'den veri alınamadı veya geçersiz bir yanıt alındı.")
else:
update.message.reply_text("API'den veri alınamadı. Lütfen daha sonra tekrar deneyin.")
def aile_sorgula_handler(update: Update, context: CallbackContext):
user_id = update.effective_user.id
chat_id = update.message.chat_id # Get the chat ID of the current channel
if chat_id == -1001814036136:
update.message.reply_text("Bu komut bu kanalda kullanılamaz. DM'den Kullanabilirsiniz")
return
if check_channel_membership(update, context):
user_id = update.effective_user.id
log_action(user_id, "aile", str(context.args))
aile_sorgula(update, context)
def status_command(update: Update, context: CallbackContext):
user_id = update.effective_user.id
# Define a list of allowed user IDs
if user_id in admin_ids:
try:
with open("bot_log.txt", "r") as log_file:
log_entries = log_file.readlines()
sorgu_sayisi = len(log_entries)
except FileNotFoundError:
sorgu_sayisi = 0
# Get system information
cpu_percent = psutil.cpu_percent(interval=1)
ram_usage = psutil.virtual_memory()
# Format the system information
status_message = (
f"💻 Bot İstatistikleri 💻nn"
f"🖥️ CPU Kullanımı: {cpu_percent}% 🖥️ ️️️️n"
f"📊 RAM Kullanımı: {ram_usage.percent}% 📊 n"
f"✅ Aktif Sorgu Sayısı : 4 ✅ n"
f"🔰 Yapılan Sorgu Sayısı {sorgu_sayisi} 🔰 nn"
f"ℹ Bot Sürümü : v1.1 ℹ"
)
# Send the status message to the user
update.message.reply_text(status_message)
else:
# User is not allowed to use the command
update.message.reply_text("Bu Komutu Kullanmaya Yetkiniz Yok!")
def reboot_command(update: Update, context: CallbackContext):
user_id = update.effective_user.id
if user_id in admin_ids:
# Log the reboot action
current_datetime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
username = update.message.from_user.username
reboot_message = f"Reboot Started {current_datetime} {username}"
with open("bot_admin_log.txt", "a") as log_file:
log_file.write(reboot_message + "n")
# Send a response message
update.message.reply_text("Bot yeniden başlatılıyor...")
else:
# User is not allowed to use the command
update.message.reply_text("Bu Komutu Kullanmaya Yetkiniz Yok!")
dp.add_handler(CommandHandler("start", start))
dp.add_handler(CommandHandler("tc", tc_sorgula_handler, pass_args=True))
dp.add_handler(CommandHandler("adsoyad", adsoyad_sorgula_handler, pass_args=True))
dp.add_handler(CommandHandler("gsmtc", gsmtc_sorgula_handler, pass_args=True))
dp.add_handler(CommandHandler("tcgsm", tcgsm_sorgula_handler, pass_args=True))
dp.add_handler(CommandHandler("yardim", help_command, pass_args=True))
dp.add_handler(CommandHandler("discord", discord_command, pass_args=True))
dp.add_handler(CommandHandler("sorgular", sorgular_command, pass_args=True))
dp.add_handler(CommandHandler("panel", panel_command, pass_args=True))
dp.add_handler(CommandHandler("aile", aile_sorgula_handler, pass_args=True))
dp.add_handler(CommandHandler("status", status_command))
dp.add_handler(CommandHandler("reboot", reboot_command))
dp.add_handler(CommandHandler("vesika", vesika_handler, pass_args=True))
dp.add_handler(CommandHandler("talk", talk_command, pass_args=True))
dp.add_handler(CommandHandler("adres", adres_handler, pass_args=True))
updater.start_polling()
updater.idle()
if __name__ == "__main__":
main()
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team