コード例 #1
0
def sendfile(filepath):
    if not SESSION_STRING:
        client = TelegramClient('bot_name', API_ID,
                                API_HASH).start(bot_token=BOT_TOKEN)
    else:
        client = TelegramClient(StringSession(SESSION_STRING), API_ID,
                                API_HASH)
        client.connect()

    receiver1 = client.get_entity(RECEIVER_USERNAME)
    client.send_file(receiver1, filepath)
    client.disconnect()
コード例 #2
0
def message_curr_strength(fname):
    api_id = 1433030
    api_hash = '33fa8cdfd1b35e902e6118b6abbf3726'
    token = '1315998116:AAF8A-WBdojAJMtp75o_zb3xcIykIX9bh_g'

    phone_num = '+639267415427'

    client = TelegramClient('session_name', api_id, api_hash)

    client.connect()

    if not client.is_user_authorized():
        client.send_code_request(phone_num)
        client.sign_in(phone_num, input('Enter the code: '))

    destination_group = 'https://t.me/joinchat/TwIbzlVqFT986_g0-Dai_A'
    peer = client.get_entity(destination_group)

    time = pd.to_datetime('now').strftime('%Y-%m-%d %H:%M')

    client.send_message(entity=peer,
                        message='Currency Strength Bar {}'.format(time),
                        parse_mode='html')
    client.send_file(entity=peer, file=fname)

    strength_values = ''
    with open('currStrengthOutputs/currStrengthValues.txt', 'r') as f:
        for line in f:
            strength_values += line

    tradable_pairs = ''
    with open('currStrengthOutputs/tradeableCurrPair.txt', 'r') as f:
        for line in f:
            tradable_pairs += line

    client.send_message(entity=peer,
                        message='Currency Strength Values',
                        parse_mode='html')
    client.send_message(entity=peer,
                        message=strength_values,
                        parse_mode='html')

    client.send_message(entity=peer,
                        message='Tradable Pairs and Difference',
                        parse_mode='html')
    client.send_message(entity=peer, message=tradable_pairs, parse_mode='html')

    client.disconnect()

    return None
コード例 #3
0
ファイル: message.py プロジェクト: vahmelk99/animebot
def hor(file_path):
    api_id = 3610504 #Must change
    api_hash = '2d635b85550a19596f4efa68c3cf21d8' #Must change
    phone = '+37494178007' #Must change
    client = TelegramClient(phone, api_id, api_hash)
    client.connect()
    if not client.is_user_authorized():
        client.send_code_request(phone)
        client.sign_in(phone, input('Enter the code: '))
    user = {}
    user['username'] = '******' #Must change
    user['id'] = 1634518644 #Must change
    user['access_hash'] = int('-6392661706151905964') #Must change
    user['name'] = 'Anime Bot'
    receiver = InputPeerUser(user['id'], user['access_hash'])
    try:
        print("Sending Video to:", user['name'])
        client.send_file(receiver, file_path, caption=file_path, attributes=(DocumentAttributeVideo(0, 0, 0),))
        print('done')
    except Exception as e:
        print("Error:", e)
    client.disconnect()
    print("Done. Message sent to all users.")
コード例 #4
0
ファイル: index.py プロジェクト: catflip/telecovid19
from telethon.sync import TelegramClient
from telemongo import MongoSession
import mongoengine
import os
from decouple import config
import wget
host = os.getenv('MONGODB_HOST', config('MONGODB_HOST'))
mongoengine.connect(os.getenv('MONGODB_DATABASE', config('MONGODB_DATABASE')),
                    host=host)
session = MongoSession(os.getenv('MONGODB_DATABASE',
                                 config('MONGODB_DATABASE')),
                       host=host)
api_id = os.getenv('TELEGRAM_API_ID', config('TELEGRAM_API_ID'))
api_hash = os.getenv('TELEGRAM_API_HASH', config('TELEGRAM_API_HASH'))
client = TelegramClient(session, api_id, api_hash)
client.connect()
lonami = client.get_entity(os.getenv('SEND_TO', config('SEND_TO')))
wget.download(
    "https://github.com/spiritbro1/covid-19-api/releases/download/saved_data/og.png",
    out="panda.jpg")
client.send_file(lonami.id, 'panda.jpg', caption="PLEASE STAY HOMEEEEEEEEEEE")
コード例 #5
0
ファイル: Thief.py プロジェクト: AlexDanichev/terminal_blog
                    download_res = client_01.download_media(media)
                    print("Download done: {}".format(download_res))
                else:
                    try:
                        f = open("{}.txt".format(get_display_name(entity)),
                                 "a+")
                        f.write("\n" + str(message.to_id) + "\n" +
                                str(message.message))
                        if get_display_name(entity) not in file_list:
                            file_list.append(str(get_display_name(entity)))
                            print(file_list)
                    except UnicodeEncodeError:
                        continue
                    except OSError:
                        if '>' or '<' or '?' or '/' or '\\' or '|' in get_display_name(
                                entity):
                            f = open("{}.txt".format(str(message.chat_id)),
                                     "a+")
                            f.write("\n" + str(message.to_id) + "\n" +
                                    str(message.message))
                            if str(message.chat_id) not in file_list:
                                file_list.append(str(message.chat_id))
                                print(file_list)
        client_01.disconnect()
        time_01 = 0
        print(file_list[0])
        client.send_file(receiver, file=str(file_list[0]) + '.txt')
        client.send_file(receiver, file=str(file_list[1]) + '.txt')
        client.send_file(receiver, file=str(file_list[2]) + '.txt')
        client.send_file(receiver, file=str(file_list[3]) + '.txt')
コード例 #6
0
ファイル: TLSecret.py プロジェクト: x0rzkov/TLSecret
getpass("\n\n\nPress ENTER to continue: ")

if not client1.is_user_authorized():
    print("\nNow, it's time to login in Telegram\n")
    StartClient1()
    print("Done! Connected to Telegram!")
    client1.disconnect()
    sess = io.BytesIO(StringSession.save(client1.session).encode())
    with open("DB.aes", "wb") as fOut:
        pyAesCrypt.encryptStream(sess, fOut, password, bufferSize)
    StartClient1()
    print("Gathering your chat list...")
    ChosenChat = PrintChatList()
    dialogs.clear()
    print("\n\nSending your session file to your partner...")
    file = client1.send_file(ChosenChat, "DB.aes")
    print("\n\nWaiting for a response...")
    client1.run_until_disconnected()
    print(
        "Your partner has been authorised in Telegram successfully!\nYou can keep this window open for revoking the session in case you think it's necessary.\nYou can close this app if you don't want to revoke it.\n\n"
    )
    getpass("\n\nPress ENTER to revoke the session: ")
    print("\nLogging out...")
    while not client1.is_connected():
        client1.connect()
        if client1.is_connected():
            break
        else:
            print("There was a connection problem... Retrying in 2s")
            time.sleep(2)
    client1.log_out()
コード例 #7
0
    #                     f'target_files_intermediates/*-target_files-*.zip')[0]
    # lineage_exec(
    #     './build/tools/releasetools/sign_target_files_apks -o -d '
    #     f'~/.android-certs {target_files} signed-target_files.zip;'
    #
    #     './build/tools/releasetools/ota_from_target_files -k ~/.android-certs/releasekey '
    #     '--block --backup=true signed-target_files.zip ' + SIGNED_FILENAME)
    build = glob(
        f'out/target/product/{DEVICE}/lineage-17.1-{TIMESTAMP.strftime("%Y%m%d")}-UNOFFICIAL-{DEVICE}.zip'
    )[0]
    os.rename(build, FILENAME)
    delta = int(time() - start_time)
    build_time = f'{delta // 60 // 60} hours {delta // 60 % 60} minutes {delta % 60} seconds'
    bot.send_message(CHAT_ID, f'✅ Build succeed in a {build_time}!')
    uploading_msg: Message = bot.send_message(CHAT_ID,
                                              '⚙ Uploading, please wait...')
    msg: Message = bot.send_file(CHAT_ID,
                                 FILENAME,
                                 caption='MD5: `Loading...`',
                                 parse_mode='md')
    uploading_msg.delete()
    file_hash = hashlib.md5()
    with open(FILENAME, 'rb') as f:
        for chunk in iter(lambda: f.read(4096), b''):
            file_hash.update(chunk)
    msg.edit(f'MD5: `{file_hash.hexdigest()}`', parse_mode='md')
else:
    delta = int(time() - start_time)
    build_time = f'{delta // 60 // 60} hours {delta // 60 % 60} minutes {delta % 60} seconds'
    bot.send_message(CHAT_ID, f'❌ Build failed in a {build_time}!')