HadisMastodonBotu/telegramMastodonBot.py

71 lines
2.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

TOKEN_Telegram = "7890923163:AAEg8TW9FpoApu2VfX1BnCXTi564Bt_mZ80" # @GunlukHadis_bot
#TOKEN_Telegram = "7859489144:AAFioKY_83xAUtX3SkjnM2vSfxLGA-0cW2g" # @ArslansahBot
from telebot import TeleBot
from mastodon import Mastodon # Mastodon.py
bot = TeleBot(TOKEN_Telegram)
# Yusuf Hoca: 816494516
# Hadis Botu: 7727645914
# Hadis Kanal: -1001205204850
data = {
816494516: -1001205204850,
# 7985753317: -1002807372190 # Yönetici komutu
}
class TelegramBot:
def __init__(self):
self.message = None
self.start()
def start(self):
@bot.message_handler(content_types=['text'])
def start(m):
dataKeys = data.keys()
if(m.from_user.id in dataKeys and m.chat.id in dataKeys and m.chat.type == "private"):
self.message = m
Arslansah = self.MastodonConnect("LOD2-WQ8fbGT42i6WeCWPvRppbj0Y1hIrOWXEXEHxRc", '9xADkvI1GYtjOHXpXOPL4V6UdiuCIz94OqJClzzYhSA', 'TZxWQBoDqSeOme05gKipQaN0yzK0EsHAH-eu13m3ZDs', 'https://arslansah.com.tr')
Teknofest = self.MastodonConnect("54dH-6gNG_Wp_uumXoi0-YqRJ3kksa9eHVaWudESrn0", '1uAxSKpOEtejPr6J6rIWMlYUdfKBqGF1CYap8-one50', 'zReeFYjrttrqX6H1Lu8vifK-49nXjJhW3idhIN3Hbhk', 'https://sosyal.teknofest.app')
self.MastodonStatus(Arslansah, "Arslanşah")
self.MastodonStatus(Teknofest, "TeknoFest")
self.TelegramStatus()
else:
bot.send_message(m.chat.id, "*Botu kullanma yetkiniz yox.*", parse_mode='Markdown')
def MastodonConnect(self, client_id, client_secret, access_token, api_base_url):
return Mastodon(
client_id= client_id,
client_secret= client_secret,
access_token= access_token,
api_base_url= api_base_url
)
def MastodonStatus(self, connection, title):
try:
status = connection.status_post(self.message.text)
message = f"<b>{title} Sosyal Medya sunucusunda Gönderi Paylaşıldı.</b>\n {status.uri}"
except:
message = f"<b>{title} Sosyal Medya sunucusunda Gönderi Paylaşılamadı.</b>\n Lütfen bot yöneticisi ile iletişime geçiniz. bc1428@vuhuv.com"
bot.send_message(self.message.chat.id, message, parse_mode='Html')
def TelegramStatus(self):
try:
chat_info = bot.get_chat(data[self.message.from_user.id])
bot.send_message(data[self.message.from_user.id], self.message.text)
message = f"*{chat_info.title} kanalında Gönderi Paylaşıldı.*"
except:
message = f"*{chat_info.title} kanalında Gönderi Paylaşılamadı.*\n Lütfen bot yöneticisi ile iletişime geçiniz. bc1428@vuhuv.com"
bot.send_message(self.message.chat.id, message, parse_mode='Markdown')
if __name__ == "__main__":
TelegramBot()
bot.polling()