コード例 #1
0
def run():
    while True:
        answer = get_message()
        if answer is not None:
            chat_id = answer['chat_id']
            text = answer['text']

            # пытаюсь разобраться с переводчиком!!!
            # Проверка на команда /btc узнаем курс биткоина
            if text.startswith('/'):

                if text == '/btc':
                    send_message(chat_id, get_btc())
                # проверка на команду /help Выдаем список всех команд для бота
                elif text == '/help':
                    send_message(chat_id, '/btc - Узнать курс Биткоина на бирже yobit.net\n'
                                          '/translate - Через данную команду можно перевести любой вводимы текст с английского на русский')
                elif '/translate ' in text:
                    # Вырезаем слово /translate
                    text_translate = text.replace('/translate ', '')
                    text_translate = get_translate(text_translate)

                    send_message(chat_id, text_translate)  # пишем перевод
                else:
                    # при получение любого иного текста выскакивает эта фраза
                    send_message(chat_id, 'Я тебя не понимаю;)')
        else:
            continue
コード例 #2
0
def main():
	#d = get_updates() 
	
	#with open('updates.json', 'w', encoding ="utf-8" ) as file: #добовляем encoding = "utf-8", что бы мы могли записывать в файл дамб с русскмими буквами)
	#	json.dump(d, file, indent = 2, ensure_ascii = False)
	
	
	
	
	while True:
		answer = get_msg()
		if answer != None:
			text = answer['text']
			if text == '/btc':
				send_msg(answer['chat_id'], get_btc())
			elif text[:2] == '/d':
				inst_id = text[3:] 
				#забираем вторую часть после /d <name> для индентификации пользователя
				#TODO если коней файла кончается на mpg - > sendVideo , если jpg -> sendPhoto
				tmp_a = myosdisk.start_the_script(inst_id)
				for i in tmp_a:
					if i.split('.')[1] == 'mp4':
						send_video(answer['chat_id'],open((os.getcwd()+"\\stories\\"+ inst_id +"\\" + i), 'rb'))
					elif i.split('.')[1] == 'jpg':
						send_photo(answer['chat_id'],open((os.getcwd()+"\\stories\\"+ inst_id +"\\" + i), 'rb'))
				
				
				send_msg(answer['chat_id'], text[3:] + "<- Grab Done, now delete temp file...")
				myosdisk.remove_files()
			elif text == '/start':
				send_msg(answer['chat_id'], 'I can send you instagram stories. \n Just type /d <name> \n Where <name> = Insagram name \n' +
				'For example: /d iamcardib \n It can take like 10 seconds before i can send you some files ')
		else:
			continue
		sleep(3)
コード例 #3
0
ファイル: bot.py プロジェクト: 123456volkov/bot
def main():
    while True:
        answer = get_message()
        if answer != None:
            if answer['text'] == '/btc':
                send_message(answer['chat_id'], get_btc())
        else:
            continue
コード例 #4
0
ファイル: bot.py プロジェクト: DimitryLenchevsky/CStutorial
def main():
    #d = get_updates()
    while True:
        answer = get_message()
        chat_id = answer['chat_id']
        text = answer['text']

        if text == '/btc':
            send_message(chat_id, get_btc())

        sleep(2)
コード例 #5
0
ファイル: bot.py プロジェクト: Andrey-Zhuk/Mybot
def main():
    while True:
        answer = get_message()
        if answer != None:
            chat_id = answer["chat_id"]
            text = answer["text"]

            if text == "/btc":
                send_message(chat_id, get_btc())
        else:
            continue
コード例 #6
0
ファイル: test_bot.py プロジェクト: Sviatik/test-bot
def main():
    old_update_id = ''
    while True:
        message = get_message()
        if message['update_id'] != old_update_id:
            if 'btc' in message['text'].lower():
                send_message(message["chat_id"], get_btc())
            elif 'usd' in message['text'].lower():
                send_message(message["chat_id"], get_usd())
            old_update_id = message['update_id']
        sleep(3)
コード例 #7
0
def main():
    while True:
        answer = get_message()
        if answer != None:
            chat_id = answer['chat_id']
            text = answer ['text']

            if text == 'bit':
                send_message(chat_id, get_btc())
        else:
            continue
        sleep(15)
コード例 #8
0
def main():
    while True:
        global mode_trans, lang
        global NOT_SUPPORTED, UNKNOWN, ON_TR_MODE, OFF_TR_MODE, MODE_TR_ON, MODE_TR_OFF
        answer = get_message()
        if answer != None:
            chat_id = answer["chat_id"]
            text = answer["text"]
            if text == "/btc":
                send_message(chat_id, get_btc())
            elif text == HELP:
                print(HELP)
                send_message(chat_id, HELP_TEXT)
            elif text == MODE_TRANS:
                if mode_trans:
                    print(MODE_TR_ON)
                    send_message(chat_id, MODE_TR_ON)
                else:
                    print(MODE_TR_OFF)
                    send_message(chat_id, MODE_TR_OFF)
            elif text == ON_TR_MODE:
                mode_trans = True
                print(MODE_TR_ON)
                send_message(chat_id, MODE_TR_ON)
            elif text == OFF_TR_MODE:
                mode_trans = False
                print(MODE_TR_OFF)
                send_message(chat_id, MODE_TR_OFF)
            elif text in dict_lang:
                lang = dict_lang[text][0]
                lang_info = dict_lang[text][1]
                print(lang)
                send_message(chat_id, lang_info)
            elif mode_trans:
                tr_text = get_translation(TR_API_KEY, text, lang)
                print(tr_text)
                send_message(chat_id, tr_text)
            elif text in dict_mess:
                mess = dict_mess[text]
                print(mess)
                send_message(chat_id, mess)
            elif text[0] == "/":
                print(NOT_SUPPORTED)
                send_message(chat_id, NOT_SUPPORTED)
            else:
                print(UNKNOWN)
                send_message(chat_id, UNKNOWN)
        else:
            sleep(2)
            continue
        sleep(2)
コード例 #9
0
def main():
    #d = get_updates()
    #with open('updates.json', 'w') as file:
    #json.dump(d, file, indent=2, ensure_ascii=False)
    while True:
        answer = get_message()
        if answer != None:
            chat_id = answer['chat_id']
            text = answer['text']
            if text == '/btc':
                send_message(chat_id, get_btc())
        else:
            continue
        sleep(2)
コード例 #10
0
ファイル: bot.py プロジェクト: VToropov1337/Scripts-examples
def main():
    while True:
        answer = get_message()
        if answer != None:
            chat_id = answer['chat_id']
            text = answer['message']

            if text == '/btc':
                send_message_to_bot(chat_id, get_btc())

        else:
            continue

        sleep(3)
コード例 #11
0
def main():
    #d = get_updates()
    while True:
        answer = get_message()
        if answer != None:
            chat_id = answer['chat_id']
            text = answer['text']

            if text == '/btc':
                send_message(chat_id, get_btc())
            else:
                continue

        sleep(2)
コード例 #12
0
def main():

    while True:
        answer = get_message()
        if answer != None:
            chat_id = answer['chat_id']
            text = answer['text']
            if text == '/btc':  # check for keyword message
                send_message(chat_id, get_btc(
                ))  # sending data at the chat from the cryptocurrency resource
        else:
            continue

            sleep(3)
コード例 #13
0
def main():


    while True:
        answer = get_message()

        if answer != None:
            id_user = answer['id_user']
            text = answer['message_text']

            if text == '/btc':
                send_message(id_user, yobit.get_btc())
        else:
            continue
        time.sleep(3)
コード例 #14
0
def main():
    # d = get_updates()
    while True:
        answer = get_message()
        if answer != None:
            chat_id = answer['chat_id']
            text = answer['text']
            # with open('updates.json', 'w') as file:
            # json.dump(d, file, indent=2, ensure_ascii=False)
            if text == '/btc':
                send_message(chat_id, get_btc())
            if text == '/love':
                send_message(chat_id, 'I Love Xenia')
            if text == '/etor':
                send_message(chat_id, 'Евро стоит ' + get_eur() + ' рублей')
        else:
            continue
        # with open('updates.json', 'w') as file:
        # json.dump(d, file, indent=2, ensure_ascii=False)
        sleep(3)
コード例 #15
0
def main():
    # Отвечать только на новые смс
    # получаем update_id каждого обновления, и затем сравнивать новую с посл
    # d = get_updates()
    # print(type(d))
    # with open('updates.json', 'w', encoding='utf-8') as file:
    #     json.dump(d, file, indent=2, ensure_ascii=False)
    while True:
        answer = get_message()
        if answer != None:
            chat_id = answer['chat_id']
            text = answer['text']

            # if text == '/btc':
            if 'курс' in text:
                send_messuge(chat_id, get_btc())
        else:
            continue

        sleep(1)
コード例 #16
0
ファイル: vasobot.py プロジェクト: AndrewClimber/vasobot
def q2a_translator(chat_id, text):
    text = text.strip().lower()
    if 'hi' in text:
        send_message(chat_id, 'You a stupid!')
    elif '/btc' in text:
        send_message(chat_id, yobit.get_btc())
    elif '/help' in text:
        helps = """
/help - help
/stop - kill bot
/btc  - btc rate
        """
        send_message(chat_id, helps)
    elif '/stop' in text:
        send_message(chat_id, 'You kill me, bastard !')
        print('Content-type: text/html\n\n')
        print("<html>I'll be back.</html>")
        return False
    else:
        send_message(chat_id)
    return True
コード例 #17
0
ファイル: bot.py プロジェクト: studiolatex/telegrambot
def main():
    #d = get_updates()
    #with open('updates.json', 'w') as file:
    #   json.dump(d, file, indent=2, ensure_ascii=False)
    #print(get_message())
    #send_message(238121714, 'ку ку')

    # вызов бесконечного цикла
    while True:
        answer = get_message()

        if answer != None:
            chat_id = answer['chat_id']
            text = answer['text']

            if text == '/btc':
                send_message(chat_id, get_btc())

            else:
                continue

        sleep(2)  #сон
コード例 #18
0
def send_btc(message):
    answer = get_btc()
    bot.send_message(message.chat.id, answer)
コード例 #19
0
ファイル: bot.py プロジェクト: vovakovtun20/BotCriptaSearcher
    if last_update_id != current_update_id:
        last_update_id = current_update_id
        chat_id = data['result'][-1]['message']['chat']['id']
        message_text = data['result'][-1]['message']['text']
        message = {'chat_id': chat_id, 'text': message_text}
        return message
    return None


def send_message(chat_id, text='wait a second'):
    url = URL + 'sendmessage?chat_id={}&text={}'.format(chat_id, text)
    requests.get(url)


while True:
    answer = get_message()
    if answer != None:

        chat_id = answer['chat_id']
        text = answer['text']

        if text == '/btc':
            send_message(chat_id, get_btc())
    else:
        continue
    sleep(2)

d = get_updates()
with open('updates.json', 'w') as file:
    json.dump(d, file, indent=2, ensure_ascii=False)
コード例 #20
0
ファイル: bot.py プロジェクト: Tooloom/First_telegram_bot
 def bitcoin(chat_id):
     send_message(chat_id, get_btc())
コード例 #21
0
def btc(message):
    bot.send_message(message.chat.id, get_btc())
コード例 #22
0
ファイル: bot.py プロジェクト: JeffFosterUK/Bot
def main():
    #d = get_updates()
    while True:
        answer = get_message()

        if answer != None:
            chat_id = answer["chat_id"]
            text = answer["text"]
        
            if text == "/btc":
                send_message(chat_id, get_btc())

            elif text == "/btc@JeffFosterUKBot":
                send_message(chat_id, get_btc())
            
            elif text == "/creator":
                send_message(chat_id, get_creator())
            
            elif text == "/creator@JeffFosterUKBot":
                send_message(chat_id, get_creator())

            elif text == "/roll":
                send_message(chat_id, get_roll())

            elif text == "/roll@JeffFosterUKBot":
                send_message(chat_id, get_roll())
        
            elif text == "/ask":
                send_message(chat_id, get_ask())

            elif text == "/ask@JeffFosterUKBot":
                send_message(chat_id, get_ask())

            elif text == "/discord":
                send_message(chat_id, get_discord())

            elif text == "/discord@JeffFosterUKBot":
                send_message(chat_id, get_discord())

            elif text == "/group":
                send_message(chat_id, get_group())

            elif text == "/group@JeffFosterUKBot":
                send_message(chat_id, get_group())

            elif text == "/group_steam":
                send_message(chat_id, get_groupsteam())

            elif text == "/group_steam@JeffFosterUKBot":
                send_message(chat_id, get_groupsteam())

            elif text == "/instagram":
                send_message(chat_id, get_instagram())

            elif text == "/instagram@JeffFosterUKBot":
                send_message(chat_id, get_instagram())

            elif text == "/steam":
                send_message(chat_id, get_steam())

            elif text == "/steam@JeffFosterUKBot":
                send_message(chat_id, get_steam())

            elif text == "/sub":
                send_message(chat_id, get_sub())

            elif text == "/sub@JeffFosterUKBot":
                send_message(chat_id, get_sub())

            elif text == "/trade":
                send_message(chat_id, get_trade())

            elif text == "/trade@JeffFosterUKBot":
                send_message(chat_id, get_trade())

            elif text == "/twitch":
                send_message(chat_id, get_twitch())

            elif text == "/twitch@JeffFosterUKBot":
                send_message(chat_id, get_twitch())

            elif text == "/vk":
                send_message(chat_id, get_vk())

            elif text == "/vk@JeffFosterUKBot":
                send_message(chat_id, get_vk())

            elif text == "/youtube":
                send_message(chat_id, get_youtube())

            elif text == "/youtube@JeffFosterUKBot":
                send_message(chat_id, get_youtube())

            elif "Бот," in text:
                send_message(chat_id, get_botsay())


        else:
            continue


        sleep(2)
コード例 #23
0
def main():
    # d = get_updates()

    while True:

        answer = get_message()

        if answer != None:
            chat_id = answer['chat_id']
            text = answer['text']

            if text == '/btc':
                send_message(chat_id, get_btc())

            if text == '/eth':
                send_message(chat_id, get_eth())

            if text == '/ltc':
                send_message(chat_id, get_ltc())

            if text == '/etc':
                send_message(chat_id, get_etc())

            if text == '/dash':
                send_message(chat_id, get_dash())

            if text == '/reminder':
                send_message(
                    chat_id, '1. Лучше начать с небольшой суммы.'
                    '2. Помните о высоких комиссиях при переводе'
                    '3. Чтобы перевести биткойн из кошелька в кошелек нужно время и немалое'
                    '4. Не стоит держать деньги в кошельке на биржe'
                    '5. Обратите внимание на другие валюты'
                    '6. Чтобы купить альткоины, запаситесь биткойнами'
                    '7.Транзакция - процесс не подлежащий оспариванию')

            if text == '/bubble':
                send_message(
                    chat_id,
                    'Четыре причины, почему биткоин — не мыльный пузырь:                              '
                    '1. Децентрализация.  Сила биткоина — децентрализация. Биткоин не принадлежит какой-либо централизованной банковской системе, поэтому стабилен.'
                    '2. Поставка.  Поставка биткоина ограничена. Добыча биткоина становится сложнее, а ценность монеты будет расти.'
                    '3. Безопасность.  Децентрализация и шифрование означают, что биткоин безопасен.'
                    '4. Доказательство мошенничества.  Поскольку все транзакции записываются, возможность мошенничества минимальна и сразу отслеживается.'
                )

            if text == '/end':
                send_message(chat_id,
                             'В 2140 году будет добыт последний Биткоин')

            if text == '/father':
                send_message(
                    chat_id,
                    'Мой создатель это Иван Бонич , если я что-то делаю не так , не ругайтесь на него сильно , пожалуйста!'
                )

            if text == '/btcfather':
                send_message(
                    chat_id,
                    'Сатоши Накамото — псевдоним создателя Биткоин. Весь мир теряется в загадках о его настоящейличности. Сатоши создал Биткоин в 2008-ом году. й первый миллион биткоинов был добыт лично Сатоши и, по всей видимости, до сих пор ему принадлежит. Исследователи до сих пор предпринимают попытки обнаружить кошельки Накамото, чтобы выйти на его след, но Сатоши сохраняет спокойствие'
                )

            if text == '/language':
                send_message(chat_id,
                             'Платежная система  Bitcoin Написана на C++')

        else:
            continue