def send_digits(message): user_id = str(message.from_user.id) data = get_allcards() cardcode = define_prefix(chosen_type) + message.text balance = get_balance(cardcode) if balance is not None: if data.get(user_id) is not None: l = data[user_id] if cardcode not in l: l.append(cardcode) data[user_id] = l else: bot.send_message(message.chat.id, messages.EXISTS, reply_markup=types.ReplyKeyboardRemove()) return None else: data[user_id] = [cardcode] with open('cards.json', 'w') as file: json.dump(data, file) bot.send_message(message.chat.id, messages.ADDED, reply_markup=types.ReplyKeyboardRemove()) else: bot.send_message(message.chat.id, messages.NOTEXIST)
def echo_reply(bot, update): text = update.message.text.lower() import re p = re.compile('^(96431085033|96439085033)\d{8}$') if p.match(text): card_no = text balance = get_balance(card_no) if balance is not None: user_id = update.message.from_user.id save_card(user_id, card_no) text = 'Баланс карты: %d' % balance bot.send_message(chat_id=update.message.chat_id, text=text) else: text = 'Карта не найдена' bot.send_message(chat_id=update.message.chat_id, text=text) else: text = 'Введите 19 цифр вашей Онай карты' bot.send_message(chat_id=update.message.chat_id, text=text)
def check(message): balance = get_balance(message.text) bot.send_message( message.chat.id, 'Balance is of this card is %d tenge\nThank you!' % balance, reply_markup=types.ReplyKeyboardRemove())
import time from onay import get_balance import telegram bot = telegram.Bot(token='271801612:AAF_3DZ-QhhFkmi7dAi_TOjkPw5Ok82eINU') user_id = 129767043 while True: balance = get_balance('9643908503307746820') bot.sendMessage(chat_id=user_id, text='Баланс %f' % balance) time.sleep(5)
import time from onay import get_balance import telegram import json bot = telegram.Bot(token='271801612:AAF_3DZ-QhhFkmi7dAi_TOjkPw5Ok82eINU') data = {} with open('cards.json', 'r') as file: data = json.load(file) while True: for user_id, card_list in data.items(): user_id = int(user_id) for card in card_list: balance = get_balance(card) if balance < 200: bot.sendMessage( chat_id=user_id, text= 'Внимание, баланс вашей карты ...%s ~ %d тг. Этого хватит меньше чем на %d поездок' % (card[-8:], balance, balance // 80)) time.sleep(60)