def send_slack(self): text = Text.get_text('slack') attachments_dict = dict() attachments_dict['text'] = text attachments = [attachments_dict] token = Configuration.get_token('slack') slack = Slacker(token[1]) slack.chat.post_message(channel=token[0], text=None, attachments=attachments, as_user=True)
def send_telegram(self): text = Text.get_text('telegram') token = Configuration.get_token('telegram') user = Configuration.get_user('lonbebot') bot = telegram.Bot(token=token[0]) for key, value in user.items(): print(key, value) bot.sendMessage(chat_id=key, text=text)
def answer(context, bot): user_id = context.message.chat_id msg_text = context.message.text status = DB.get_info(user_id, 'status') if status == 1 and msg_text.isdigit(): msg_text = int(msg_text) DB.update_user(user_id, 'temp', msg_text) if pr.get_quantity(DB.get_info(user_id, 'temp')[0]) >= msg_text: data = DB.get_info(user_id, 'temp')[0] text = tx.get_text('status_1').format( data, msg_text, msg_text * pr.get_price(data)) bot.bot.send_message(user_id, text, reply_markup=final_question()) DB.update_user(user_id, 'status', 2)
def ans_pr(update, bot): query = update.callback_query user_id = query.message.chat_id msg_id = query.message.message_id status = DB.get_info(user_id, 'status') if query.data in pr.get_products_name() and status == 0: DB.update_user(user_id, 'temp', query.data) text = "Продукт успешно выбран" bot.bot.edit_message_text(chat_id=user_id, message_id=msg_id, text=text, reply_markup=product_names(query.data)) DB.update_user(user_id, 'status', 1) text = tx.get_text('pr_ch').format( DB.get_info(user_id, 'temp')[0], pr.get_quantity(query.data)) bot.bot.send_message(user_id, text)
def send_teams(self): text = Text.get_text('teams') token = Configuration.get_token('teams') headers = { 'Content-Type': 'Application/JSON;charset=utf-8', } card = 'MessageCard' color = '0072C6' title = '' data = '{"@context":"'+token[0]+'","@type":"'+card+'","themeColor":"'+color+'","title":"'+title+'","text":"'+text+'"}' response = requests.post(token[1], headers=headers, data=data.encode('utf-8'))
def start(context, bot): user_id = context.message.chat_id if not DB.check_user(user_id): DB.create_user(context.message) bot.bot.send_message(user_id, tx.get_text('start'))
def buy(context, bot): user_id = context.message.chat_id text = tx.get_text('buy') bot.bot.send_message(user_id, text, reply_markup=product_names())