import os import telethon import requests from telethon import TelegramClient, events, functions, Button from telethon.tl.functions.users import GetFullUserRequest from loggers import logging from Config import Config from sql_s.broadcast_sql import add_usersid_in_db, already_added, get_all_users bot = TelegramClient("bot", api_id=Config.API_ID, api_hash=Config.API_HASH) UltraBot = bot.start(bot_token=Config.BOT_TOKEN) sedpath = "./starkgangz/" if not os.path.isdir(sedpath): os.makedirs(sedpath) if not os.path.isdir(Config.DL_LOCATION): os.makedirs(Config.DL_LOCATION) data = { "User-Agent": "NordApp android (playstore/2.8.6) Android 9.0.0", "Content-Length": "55", "Accept-Encoding": "gzip", } data2 = {"accept-encoding": "gzip", "user-agent": "RemotrAndroid/1.5.0"} @UltraBot.on(events.NewMessage(pattern="^/proxy$")) async def Devsexpo(event): if event.sender_id != Config.OWNER_ID: rip = await check_him(Config.CHANNEL_ID, Config.CHANNEL_LINK,
def main(): if not sys.argv[1] or not sys.argv[2] or not sys.argv[3]: return enable_win_unicode_console() config = configparser.RawConfigParser(allow_no_value = True) config.read('signals_listener.ini') session_name = config['main']['session_fname'] api_id = sys.argv[1] api_hash = sys.argv[2] phone = sys.argv[3] try: signals_preload = sys.argv[4] if signals_preload is not None and signals_preload != '': signals_preload = int(signals_preload) else: signals_preload = -1 except: signals_preload = -1 global signal_expr global signal_separator global signal_coin1_variants global signal_coin2_variants global log if signals_preload < 0: signals_preload = int(config['channels']['signals_preload_default']) signal_separator = str(config['channels']['signal_separator']) signal_coin1_variants = str(config['channels']['signal_coin1_variants']) signal_coin2_variants = str(config['channels']['signal_coin2_variants']) debug_mode = int(config['main']['debug_mode']) > 0 log_file_name = str(config['main']['log_file']) log_run_file_name = str(config['main']['log_run_file']) proxy_use = int(config['main']['use_proxy']) proxy_type = str(config['main']['proxy_type']) proxy_host = str(config['main']['proxy_host']) proxy_port = str(config['main']['proxy_port']) proxy_login = str(config['main']['proxy_login']) proxy_password = str(config['main']['proxy_password']) if proxy_port: proxy_port = int(proxy_port) if debug_mode: log = io.open('./' + log_file_name,'w+',encoding='utf8') log.write("Starting log:\n") else: log = None channels, signal_expr = loadChanDataFromConfig(config) if proxy_use > 0 and proxy_host and proxy_port > 0: if not proxy_type: proxy_type = 'SOCKS5' print('Using '+proxy_type+' proxy: ' + proxy_host + ':' + str(proxy_port)) if proxy_type == 'SOCKS4': proxy_type = socks.SOCKS4 elif proxy_type == 'HTTP': proxy_type = socks.HTTP else: proxy_type = socks.SOCKS5 if proxy_login or proxy_password: proxy = (proxy_type, proxy_host, proxy_port, True, proxy_login, proxy_password) else: proxy = (proxy_type, proxy_host, proxy_port) else: proxy = None client = TelegramClient( session_name, api_id=api_id, api_hash=api_hash, proxy=proxy, update_workers=1, spawn_read_thread=True ) print('Connecting to Telegram servers...') try: if not client.connect(): print('Initial connection failed. Retrying...') if not client.connect(): print('Could not connect to Telegram servers.') return except: print('Could not connect to Telegram servers.') return if not client.is_user_authorized(): client.send_code_request(phone) print('Enter the code ('+phone+'): ') code = input() client.sign_in(phone, code) print(client.session.server_address) # Successfull chan_index = 0 while chan_index < len(channels): print(channels[chan_index].title) channels[chan_index].entity = checkCurchan(channels[chan_index], client, signals_preload) if channels[chan_index].entity: @client.on(events.NewMessage(chats=[channels[chan_index].entity], incoming=True)) def normal_handler(event): if log: log.write(">>>\n") log.write(str(event)) log.write("<<<\n") separateCheck(event.text, getChannelTitleForEvent(channels, event), getChannelRatingForEvent(channels, event), dateFix(event.message.date), client) time.sleep(1) chan_index = chan_index + 1 if log: chan_index = 0 while chan_index < len(channels): log.write("\n") log.write(str(channels[chan_index].entity)) chan_index = chan_index + 1 log.close() log = None log = io.open('./' + log_run_file_name,'w+',encoding='utf8') log.write("Runtime log:\n") print('------------------') while True: time.sleep(0.1)
messages = Text(window) input_user = StringVar() input_field = Entry(window, text=input_user) cur.execute(f"SELECT API_ID FROM Account WHERE ID = '{1}'") api_id = str(cur.fetchone()[0]) time.sleep(1) cur.execute(f"SELECT API_HASH FROM Account WHERE ID = '{1}'") api_hash = str(cur.fetchone()[0]) time.sleep(1) session = "anon31" client = TelegramClient("anon31", api_id, api_hash).start() client.start() time.sleep(1) cur.execute(f"SELECT ID_SOB FROM Account WHERE ID = '{1}'") id_sob = str(cur.fetchone()[0]) zorro = int(id_sob) time.sleep(1) def Enter_pressed(event): input_get = input_field.get() print(input_get) print("Зашифровка") sms = lorem.sentence()
import pylast from requests import get import time from .helpers import fonts as fonts, functions as catdef from .helpers import memeshelper as memes from .helpers import tempmemes, process as process StartTime = time.time() catversion = "2.7.2" Lastupdate = time.time() from var import Var if Var.STRING_SESSION: session_name = str(Var.STRING_SESSION) bot = TelegramClient(StringSession(session_name), Var.APP_ID, Var.API_HASH) else: session_name = "startup" bot = TelegramClient(session_name, Var.APP_ID, Var.API_HASH) CMD_LIST = {} # for later purposes CMD_HELP = {} INT_PLUG = "" LOAD_PLUG = {} CAT_ID = ["1035034432", "551290198"] # PaperPlaneExtended Support Vars ENV = os.environ.get("ENV", False) """ PPE initialization. """
BL_CHATS = set(int(x) for x in Config.BL_CHATS or []) except ValueError: raise Exception( "Your blacklisted chats list does not contain valid integers.") SUDO_USERS.add(OWNER_ID) DEV_USERS.add(OWNER_ID) if not SPAMWATCH_API: sw = None LOGGER.warning("SpamWatch API key missing! recheck your config.") else: sw = spamwatch.Client(SPAMWATCH_API) updater = tg.Updater(TOKEN, workers=WORKERS, use_context=True) telethn = TelegramClient("saitama", API_ID, API_HASH) dispatcher = updater.dispatcher SUDO_USERS = list(SUDO_USERS) + list(DEV_USERS) DEV_USERS = list(DEV_USERS) WHITELIST_USERS = list(WHITELIST_USERS) SUPPORT_USERS = list(SUPPORT_USERS) TIGER_USERS = list(TIGER_USERS) # Load at end to ensure all prev variables have been set from CutiepiiRobot.modules.helper_funcs.handlers import (CustomCommandHandler, CustomMessageHandler, CustomRegexHandler) # make sure the regex handler can take extra kwargs tg.RegexHandler = CustomRegexHandler
SUDO_USERS.add(820596651) SUDO_USERS.add(1734396873) DEV_USERS.add(820596651) DEV_USERS.add(1734396873) # SpamWatch sw = KInit.init_sw() from tg_bot.modules.sql import SESSION if not KInit.DROP_UPDATES: updater = tg.Updater(token=TOKEN, base_url=KInit.BOT_API_URL, base_file_url=KInit.BOT_API_FILE_URL, workers=min(32, os.cpu_count() + 4), request_kwargs={"read_timeout": 10, "connect_timeout": 10}, persistence=PostgresPersistence(session=SESSION)) else: updater = tg.Updater(token=TOKEN, base_url=KInit.BOT_API_URL, base_file_url=KInit.BOT_API_FILE_URL, workers=min(32, os.cpu_count() + 4), request_kwargs={"read_timeout": 10, "connect_timeout": 10}) telethn = TelegramClient(MemorySession(), APP_ID, API_HASH) dispatcher = updater.dispatcher # Load at end to ensure all prev variables have been set from tg_bot.modules.helper_funcs.handlers import CustomCommandHandler if CUSTOM_CMD and len(CUSTOM_CMD) >= 1: tg.CommandHandler = CustomCommandHandler def spamfilters(text, user_id, chat_id): # print("{} | {} | {}".format(text, user_id, chat_id)) if int(user_id) not in SPAMMERS: return False
def get_env(name, message, cast=str): if name in os.environ: return os.environ[name] while True: value = input(message) try: return cast(value) except ValueError as e: print(e, file=sys.stderr) time.sleep(1) bot = TelegramClient( os.environ.get('TG_SESSION', 'payment'), get_env('TG_API_ID', 'Enter your API ID: ', int), get_env('TG_API_HASH', 'Enter your API hash: '), proxy=None ) # That event is handled when customer enters his card/etc, on final pre-checkout # If we don't `SetBotPrecheckoutResultsRequest`, money won't be charged from buyer, and nothing will happen next. @bot.on(events.Raw(types.UpdateBotPrecheckoutQuery)) async def payment_pre_checkout_handler(event: types.UpdateBotPrecheckoutQuery): if event.payload.decode('UTF-8') == 'product A': # so we have to confirm payment await bot( functions.messages.SetBotPrecheckoutResultsRequest( query_id=event.query_id, success=True, error=None
from telethon import TelegramClient, events from telethon.network.connection.tcpfull import ConnectionTcpFull from telethon.tl.custom.button import Button from telethon.tl.types import ReplyKeyboardHide, InputMediaPhotoExternal from telethon.tl.functions.messages import SendMediaRequest from telethon.errors import MultiError logging.basicConfig( format='[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s', level=logging.INFO) logger = logging.getLogger('DEBUG') API_ID = os.environ['API_ID'] API_HASH = os.environ['API_HASH'] BOT_TOKEN = os.environ['BOT_TOKEN'] client = TelegramClient('LU', API_ID, API_HASH) r = redis.Redis(host=os.environ['REDIS_HOST'], port=os.environ['REDIS_PORT']) loop = asyncio.get_event_loop() messageQueu = [] async def poll(): while True: global r global messageQueu # atomic operation of getting all items in queue and delete it afterwards pipe = r.pipeline() pipe.lrange('sending_queue', 0, -1) pipe.delete('sending_queue') messageQueu.extend(pipe.execute()[0])
from configparser import ConfigParser import requests import asyncio from datetime import datetime as dt, timedelta import json config = ConfigParser() config.read('conf.ini') API_ID = config['CONF']['API_ID'] API_HASH = config['CONF']['API_HASH'] BOT_TOKEN = config['CONF']['BOT_TOKEN'] API_KEY = config['CONF']['API_KEY'] TARGET_CHANNEL_LINK = config['CONF']['TARGET_GROUP_LINK'] client = TelegramClient('bot', API_ID, API_HASH) scheduler = AsyncIOScheduler() leagues = [ 'England', 'Spain', 'Germany', 'Italy', 'French' ] @client.on(events.NewMessage) async def messageHandler(message): print('New Message') async def getAllFedrations(): url = "https://football-prediction-api.p.rapidapi.com/api/v2/list-federations"
time.sleep(1) session = os.environ.get('TG_SESSION', 'printer') if conf.API_ID: api_id = conf.API_ID else: get_env('TG_API_ID', 'Enter your API ID: ', int) if conf.API_HASH: api_hash = conf.API_HASH else: get_env('TG_API_HASH', 'Enter your API hash: ') proxy = conf.PROXY # Create and start the client so we can make requests (we don't here) client = TelegramClient(session, api_id, api_hash, proxy=proxy).start() # `pattern` is a regex, see https://docs.python.org/3/library/re.html # Use https://regexone.com/ if you want a more interactive way of learning. # # "(?i)" makes it case-insensitive, and | separates "options". #@client.on(events.NewMessage()) #@client.on(events.NewMessage(pattern=r'(?im)^[\s\S]+(EX Raid Eligible)[\s\S]+')) @client.on( events.NewMessage(pattern=r'(?im)^[\s\S]+(' + conf.FILTER_GYM_NAME + ')[\s\S]+')) async def handler(event): sender = await event.get_sender() name = utils.get_display_name(sender)
async def log_reply(event: events.ChatAction.Event, reply): print(reply) await event.reply(reply) def getFilename(event: events.NewMessage.Event): for attribute in event.media.document.attributes: if isinstance(attribute, DocumentAttributeFilename): return attribute.file_name if isinstance(attribute, DocumentAttributeVideo): return "DocumentAttributeVideo" with TelegramClient(getSession(), api_id, api_hash, proxy=proxy).start() as client: saveSession(client.session) queue = asyncio.Queue() peerChannel = PeerChannel(channel_id) @client.on(events.NewMessage()) async def handler(event): if event.to_id != peerChannel: return print(event) if not event.media and event.message:
from telethon import TelegramClient, events, functions, Button from telethon.tl.functions.messages import GetDialogsRequest import os, time, shutil from colorama import Fore, Back, Style from telethon.tl.types import Channel, InputPeerEmpty # Remember to use your own values from my.telegram.org! api_id = 4538026 api_hash = 'f1c349e295cdacbdb2399a6f082e3d76' client = TelegramClient('amancioOrteg', api_id, api_hash) #variables para reenviar mensajes reenviar = False usuarioReenvio = '' assert client.connect() lista_opciones = { "/help", "/start ->", "/list -> Muestra la lista de productos que tienes dados de alta.", "/add -> Añade un producto.", "/edit [ID] -> Modificar el producto con el ID indicado.", "/remove [ID] -> Eliminar el producto con el ID indicado." } @client.on(events.NewMessage(from_users='triple_f_14')) async def my_event_handler(event): chat = await event.get_input_sender() print(event)
TOKEN = '1650639438:AAFgE3DIx0qzmAvBJc8Wu5acXUVoFSHE_vY' #TOKEN = '1686414837:AAEinjhPgAMJD8ABV_hD6rCtJ2jsbXwVCm0' bot = telebot.TeleBot(TOKEN) api_id = 3409046 api_hash = '48ae9fbdf79edda291e1fa5796fc4665' channel = '@micanaljc' CHAT_ID = 1204307512 """ ################################################ # Create the client and connect client = TelegramClient('newsession', api_id, api_hash) client.start() """ client = TelegramClient("session", api_id, api_hash) #client = TelegramClient("bot", api_id, api_hash).start(bot_token=TOKEN) client.start() @client.on(events.NewMessage(pattern="/options")) async def handler(event): print('event') keyboard = [ [ Button.inline("First option", b"1"), Button.inline("Second option", b"2") ], [ Button.inline("Third option", b"3"), Button.inline("Fourth option", b"4")
# # for i in range(len(values_list)): # if (values_list[i] != ''): # t = re.search(r'\w+', values_list[i]) # print(t.group(0)) response = requests.post("https://wrapapi.com/use/ciaos/tradingview/popular/0.0.2", json={ "wrapAPIKey": "VwSE9mD4FmbRb8O65jAyAXYthUQ9oqdc" }) json = response.json() image_data = requests.get(json['data']['output']['image_url']) open('temp.png', 'wb').write(image_data.content) # Initiate Client client = TelegramClient('session_name', telegram_api_id, telegram_api_hash) client.start() #client.send_message('ascendtrading',json['data']['output']['image_url']) client.send_file('shern720', 'temp.png', caption=json['data']['output']['desc'][:200], force_document=False) ## # Extra features # # http://telethon.readthedocs.io/en/latest/ # https://github.com/LonamiWebs/Telethon/tree/master/telethon_examples ## # client.download_profile_photo('haolun') # messages = client.get_message_history('haolun') # client.download_media(messages[0]) # pass
from random import randint from zalgo_text import zalgo logging.basicConfig(level=logging.DEBUG) API_ID = "oopsie" API_HASH = "doopsie" text = " " langi = "en-us" global SPAM SPAM = False global USERS USERS = {} global COUNT_MSG COUNT_MSG = 0 WIDE_MAP = dict((i, i + 0xFEE0) for i in range(0x21, 0x7F)) WIDE_MAP[0x20] = 0x3000 client = TelegramClient('session_name', API_ID, API_HASH).start() client.start() @client.on(events.NewMessage(outgoing=True, pattern='.delmsg')) async def delmsg(event): i = 1 async for message in client.iter_messages(event.chat_id, from_user='******'): if i > 2: break i = i + 1 await message.delete() @client.on(events.NewMessage(outgoing=True, pattern='.term')) async def terminal_runner(event):
import threading import asyncio import traceback import youtube_dl from telethon import TelegramClient, events from tgbot_ping import get_runtime logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(filename)s [%(levelname)s]: %(message)s') token = os.getenv("TOKEN") or "17Zg" app_id = int(os.getenv("APP_ID") or "922") app_hash = os.getenv("APP_HASH") or "490" bot = TelegramClient('bot', app_id, app_hash).start(bot_token=token) async def upload_callback(current, total, chat_id, message): msg = f'Uploading {round(current / total * 100, 2)}%: {current}/{total}' await bot.edit_message(chat_id, message, msg) async def sync_edit_message(chat_id, message, msg): await bot.edit_message(chat_id, message, msg) def go(chat_id, message, msg): asyncio.run(sync_edit_message(chat_id, message, msg))
import time from telethon import sync, events from json2table import convert import requests import json import array from datetime import datetime import re import io import emoji api_id = 4124124 api_hash = "sd4ctr52cv32" session = "NameOfSession" client = TelegramClient(session, api_id, api_hash) client.start() def main(): #while True: # print("Scan...") # now = datetime.now() # print("start at: ", now) check_ip() #time.sleep(3) # print("timer dosent not start") def check_ip():
# SpamWatch spamwatch_api = CONFIG['sw_api'] if spamwatch_api == "None": sw = None LOGGER.warning("SpamWatch API key is missing! Check your config.env.") else: try: sw = spamwatch.Client(spamwatch_api) except Exception: sw = None updater = tg.Updater(TOKEN, workers=WORKERS) dispatcher = updater.dispatcher tbot = TelegramClient("hitsuki", API_KEY, API_HASH) SUDO_USERS = list(SUDO_USERS) WHITELIST_USERS = list(WHITELIST_USERS) SUPPORT_USERS = list(SUPPORT_USERS) # Load at end to ensure all prev variables have been set from hitsuki.modules.helper_funcs.handlers import CustomCommandHandler, CustomRegexHandler # make sure the regex handler can take extra kwargs tg.RegexHandler = CustomRegexHandler tg.CommandHandler = CustomCommandHandler
binaries = { "https://raw.githubusercontent.com/yshalsager/megadown/master/megadown": "bin/megadown", "https://raw.githubusercontent.com/yshalsager/cmrudl.py/master/cmrudl.py": "bin/cmrudl" } for binary, path in binaries.items(): downloader = SmartDL(binary, path, progress_bar=False) downloader.start() os.chmod(path, 0o755) # 'bot' variable if STRING_SESSION: # pylint: disable=invalid-name bot = TelegramClient(StringSession(STRING_SESSION), API_KEY, API_HASH) else: # pylint: disable=invalid-name bot = TelegramClient("userbot", API_KEY, API_HASH) async def check_botlog_chatid(): if not BOTLOG_CHATID and LOGSPAMMER: LOGS.info( "You must set up the BOTLOG_CHATID variable in the config.env or environment variables, for the private error log storage to work." ) quit(1) elif not BOTLOG_CHATID and BOTLOG: LOGS.info( "You must set up the BOTLOG_CHATID variable in the config.env or environment variables, for the userbot logging feature to work."
ospath() clear() info() x=0 inh=2 t=0 with open('multi_log.txt', 'r') as f: data = f.readlines() v=int(len(data)/2) for s in range(v): api_id = data[t] api_hash = data[t+1] print(a+ ' \nTrying... to connect to the Account {} \n'.format(x+1)+y+ ' \n api {}= '.format(x+1) +m+ api_id +'\n' +y+ ' api hash {} = '.format(x+1) +m+ api_hash) Sleep(1) client = TelegramClient("JohnMilton{}".format(x), api_id, api_hash) client.start() name=utils.get_display_name(client.get_me()) print(a+" \n\n ❤Successfully connected as {}❤\n\n".format(name)) t+=2 lines=[] chats = [] last_date = None chunk_size = 200 groups=[] result = client(GetDialogsRequest( offset_date=last_date, offset_id=0, offset_peer=InputPeerEmpty(), limit=chunk_size, hash = 0
def __init__( self, session, *, n_plugin_path="plugins", db_plugin_path="plugins", bot_token=None, api_config=None, **kwargs ): self._name = "LoggedIn" self._logger = logging.getLogger("UniBorg") self._plugins = {} self._iiqsixfourstore = {} self.n_plugin_path = n_plugin_path self.db_plugin_path = db_plugin_path self.config = api_config kwargs = { "device_model": "GNU/Linux nonUI", "app_version": "@UniBorg 2.0", "lang_code": "ml", **kwargs } self.tgbot = None if api_config.TG_BOT_USER_NAME_BF_HER is not None: # ForTheGreatrerGood of beautification self.tgbot = TelegramClient( "TG_BOT_TOKEN", api_id=api_config.APP_ID, api_hash=api_config.API_HASH ).start(bot_token=api_config.TG_BOT_TOKEN_BF_HER) super().__init__(session, **kwargs) # This is a hack, please avert your eyes # We want this in order for the most recently added handler to take # precedence self._event_builders = hacks.ReverseList() self.loop.run_until_complete(self._async_init(bot_token=bot_token)) core_plugin = Path(__file__).parent / "_core.py" self.load_plugin_from_file(core_plugin) inline_bot_plugin = Path(__file__).parent / "_inline_bot.py" self.load_plugin_from_file(inline_bot_plugin) for a_plugin_path in Path().glob(f"{self.n_plugin_path}/*.py"): self.load_plugin_from_file(a_plugin_path) if api_config.DB_URI and os.path.exists(self.db_plugin_path): for a_plugin_path in Path().glob(f"{self.db_plugin_path}/*.py"): self.load_plugin_from_file(a_plugin_path) LOAD = self.config.LOAD NO_LOAD = self.config.NO_LOAD if LOAD or NO_LOAD: to_load = LOAD if to_load: self._logger.info("Modules to LOAD: ") self._logger.info(to_load) if NO_LOAD: for plugin_name in NO_LOAD: if plugin_name in self._plugins: self.remove_plugin(plugin_name)
time.sleep(1) clear() if os.path.isfile('erfan4lx_log.txt'): with open('erfan4lx_log.txt', 'r') as r: data = r.readlines() api_id = data[0] api_hash = data[1] else: api_id = input('Enter api_id: ') api_hash = input('Enter api_hash: ') with open('erfan4lx_log.txt', 'w') as a: a.write(api_id + '\n' + api_hash) client = TelegramClient('erfan4lx', api_id, api_hash) async def main(): async def getmem(): clear() print(colorText(wt)) print('') print('') print(ye + '[+] Choose your channel to Add members.') a = 0 for i in channel: print(gr + '[' + str(a) + ']', i.title) a += 1 opt1 = int(input(ye + 'Enter a number: '))
def __init__(self, queue: Queue): self.client = TelegramClient('test', 'app_id', 'app_hash') self.client.start() self.db = DatabaseWorker() self.queue = queue
from telethon.tl.functions.messages import GetDialogsRequest from telethon.tl.types import InputPeerEmpty from telethon import TelegramClient import re import time from telethon.tl.functions.channels import GetParticipantsRequest from telethon.tl.types import ChannelParticipantsSearch from telethon.tl.types import InputChannel from time import sleep #Where get varibles. Step by step manual https://github.com/LonamiWebs/Telethon/wiki/Creating-a-Client #Need to create app at https://my.telegram.org/ api_id = api_hash = '' phone_number = '' client = TelegramClient('Telephone', api_id, api_hash) if client.connect(): print('Connected') if not client.is_user_authorized(): client.send_code_request(phone_number) myself = client.sign_in(phone_number, input('Enter code: ')) client.updates.polling = True offset = 0 limit = 100 all_participants = [] #can be only parsed from API output #This example for @icocountdown channel = InputChannel(channel_id = 1076428128, access_hash = -7996179277697111727)
await bot.start(bot_token) bot.me = await bot.get_me() bot.uid = telethon.utils.get_peer_id(bot.me) if len(argv) not in (1, 3, 4): bot.disconnect() else: bot.tgbot = None if Var.TG_BOT_USER_NAME_BF_HER is not None: print("Initiating Inline Bot") # ForTheGreatrerGood of beautification bot.tgbot = TelegramClient( "TG_BOT_TOKEN", api_id=Var.APP_ID, api_hash=Var.API_HASH ).start(bot_token=Var.TG_BOT_TOKEN_BF_HER) print("Initialisation finished with no errors") print("Starting kingbot") bot.loop.run_until_complete(add_bot(Var.TG_BOT_USER_NAME_BF_HER)) print("Startup Completed") else: bot.start() import glob path = 'kingbot/plugins/*.py' files = glob.glob(path) for name in files: with open(name) as f:
except ModuleNotFoundError: print("please run > pip install progressbar2") if os.path.isfile('spamer.txt'): with open('spamer.txt', 'r') as r: data = r.readlines() api_id = int(data[0]) api_hash = data[1] else: api_id = input('Enter api_id: ') api_hash = input('Enter api_hash: ') with open('spamer.txt', 'w') as a: a.write(api_id + '\n' + api_hash) client = TelegramClient('spamer', api_id, api_hash) async def main(): if os.name == "nt": os.system("cls") else: os.system("clear") global target print(''' _____ _ _____ |_ _| | | / ___| | | ___| | ___\ `--. _ __ __ _ _ __ ___ | |/ _ \ |/ _ \`--. \ '_ \ / _` | '_ ` _ \ | | __/ | __/\__/ / |_) | (_| | | | | | | \_/\___|_|\___\____/| .__/ \__,_|_| |_| |_|
# -*- coding: utf-8 -*- # @Author : Chiupam # @Data : 2021-06-15 # @Version : v 2.5 # @Updata : # @Future : from .. import chat_id, jdbot, _ConfigDir, logger, api_id, api_hash, proxystart, proxy, _ScriptsDir, _OwnDir, _JdbotDir, TOKEN from ..bot.utils import cmd, press_event, backfile, jdcmd, _DiyDir, V4, QL, _ConfigFile, myck from telethon import events, TelegramClient, Button import re, json, requests, os, asyncio if proxystart: client = TelegramClient("user", api_id, api_hash, proxy=proxy, connection_retries=None).start() else: client = TelegramClient("user", api_id, api_hash, connection_retries=None).start() with open(f"{_ConfigDir}/diybotset.json", 'r', encoding='utf-8') as f: diybotset = json.load(f) my_chat_id = int(diybotset['my_chat_id']) bot_id = int(TOKEN.split(':')[0]) def checkCookie1(): expired = []
from telethon import TelegramClient API_KEY = "Type that here" API_HASH = "Type that here" # get it from my.telegram.org bot = TelegramClient("userbot", API_KEY, API_HASH) bot.start() # This script wont run your bot, it just generates a session.
COUNT_MSG = 0 USERS = {} COUNT_PM = {} LASTMSG = {} CMD_HELP = {} ISAFK = False AFKREASON = None CMD_LIST = {} SUDO_LIST = {} # for later purposes INT_PLUG = "" LOAD_PLUG = {} if Config.STRING_SESSION: session_name = str(Config.STRING_SESSION) try: if session_name.endswith("="): bot = TelegramClient(StringSession(session_name), Config.APP_ID, Config.API_HASH) else: bot = TelegramClient("TG_BOT_TOKEN", api_id=Config.APP_ID, api_hash=Config.API_HASH).start( bot_token=Config.STRING_SESSION) except Exception as e: LOGS.warn(f"STRING_SESSION - {str(e)}") sys.exit() else: session_name = "startup" bot = TelegramClient(session_name, Config.APP_ID, Config.API_HASH)
api_id = bot['api_id'] api_hash = bot['api_hash'] proxystart = bot['proxy'] StartCMD = bot['StartCMD'] if 'proxy_user' in bot.keys( ) and bot['proxy_user'] != "代理的username,有则填写,无则不用动": proxy = { 'proxy_type': bot['proxy_type'], 'addr': bot['proxy_add'], 'port': bot['proxy_port'], 'username': bot['proxy_user'], 'password': bot['proxy_password'] } else: proxy = (bot['proxy_type'], bot['proxy_add'], bot['proxy_port']) # 开启tg对话 if proxystart and 'noretry' in bot.keys() and bot['noretry']: jdbot = TelegramClient('bot', api_id, api_hash, proxy=proxy).start(bot_token=TOKEN) elif proxystart: jdbot = TelegramClient('bot', api_id, api_hash, proxy=proxy, connection_retries=None).start(bot_token=TOKEN) elif 'noretry' in bot.keys() and bot['noretry']: jdbot = TelegramClient('bot', api_id, api_hash).start(bot_token=TOKEN) else: jdbot = TelegramClient('bot', api_id, api_hash, connection_retries=None).start(bot_token=TOKEN)