def show_new_bots(bot, update, chat_data, back_button=False): chat_id = update.effective_chat.id channel = helpers.get_channel() buttons = [[ InlineKeyboardButton("Show in BotList", url="http://t.me/{}/{}".format( channel.username, channel.new_bots_mid)), InlineKeyboardButton("Share", switch_inline_query=messages.NEW_BOTS_INLINEQUERY) ]] if back_button: buttons[0].insert( 0, InlineKeyboardButton(captions.BACK, callback_data=util.callback_for_action( CallbackActions.SELECT_CATEGORY))) reply_markup = InlineKeyboardMarkup(buttons) reply_markup, callback = botlistchat.append_delete_button( update, chat_data, reply_markup) msg = bot.formatter.send_or_edit( chat_id, _new_bots_text(), to_edit=util.mid_from_update(update), reply_markup=reply_markup, reply_to_message_id=util.mid_from_update(update)) callback(msg) return ConversationHandler.END
def last_update_job(bot, job: Job): ## SEND A MESSAGE # user_ids = [u.chat_id for u in User.select()] # not_sent = list() # for uid in user_ids: # import bot as botlistbot # try: # bot.sendMessage(uid, "Hey, check out my new Keyboard! 😍", # reply_markup=ReplyKeyboardMarkup(botlistbot._main_menu_buttons())) # except TelegramError: # not_sent.append(uid) # pprint(not_sent) last_update = helpers.get_channel().last_update if last_update: today = datetime.date.today() delta = datetime.timedelta(days=7) difference = today - last_update if difference > delta: for a in settings.MODERATORS: try: bot.sendMessage( a, "Last @BotList update was {} days ago. UPDATE NOW YOU CARNT! /admin" .format(difference.days)) except TelegramError: pass
async def on_member_join(member): """ New member join event :param member: A Member object representing the user that joined. """ # Find the general channel object general = helpers.get_channel('sorting', member.server) # send join message to general join_msg = member.mention + ' Welcome to the UCC discord server! Please state what group you are in or if you are an independent pilot. An admin will sort you accordingly as soon as possible.' await bot.send_message(general, join_msg)
async def on_member_remove(member): """ Member leaves server event :param member: A Member object representing the user that left. """ # Find the general channel object general = helpers.get_channel(config_values.general_channel_name, member.server) # send leave message to general leave_msg = member.name + config_values.leave_msg await bot.send_message(general, leave_msg)
async def on_member_join(member): """ New member join event :param member: A Member object representing the user that joined. """ # Find the general channel object general = helpers.get_channel(config_values.general_channel_name, member.server) # send join message to general join_msg = member.mention + config_values.join_msg await bot.send_message(general, join_msg)
def last_update_job(bot, job: Job): return # make admins happy :) last_update = helpers.get_channel().last_update if last_update: today = datetime.date.today() delta = datetime.timedelta(days=10) difference = today - last_update if difference > delta: for admin in settings.ADMINS: try: bot.sendMessage( admin, f"Last @BotList update was {difference.days} days ago. " f"UPDATE NOW YOU CARNT! /admin", ) except TelegramError: pass
def send_botlist(bot, update, resend=False, silent=False): log.info("Re-sending BotList..." if resend else "Updating BotList...") channel = helpers.get_channel() revision = Revision.get_instance() revision.nr += 1 revision.save() all_categories = Category.select_all() botlist = BotList(bot, update, channel, resend, silent) if resend: botlist.delete_full_botlist() botlist.update_intro() botlist.update_categories(all_categories) botlist.update_new_bots_list() botlist.update_category_list() botlist.send_footer() botlist.finish() channel.save() Statistic.of(update, 'send', 'botlist (resend: {})'.format(str(resend)), Statistic.IMPORTANT)
import helpers users = helpers.get_users() print("run_channels | users | get", len(users)) for u in users: print("= = = = = = = = = =") if \ u['twitch_views'].isdigit() is not True or \ u['twitch_followers'].isdigit() is not True \ : print("- - - - - - - - - -") try: print("run_channels | channel | user ", u) channel = helpers.get_channel(u) print("run_channels | channel | channel ", channel) u['twitch_views'] = channel['views'] u['twitch_followers'] = channel['followers'] except Exception as e: print("\nrun_channels | channel | error", e, "\n") if \ u['twitch_videos_count_total'].isdigit() is not True or \ u['twitch_videos_count_fortnite'].isdigit() is not True or \ u['twitch_videos_percentage_fortnite'].isdigit() is not True \ : print("- - - - - - - - - -") try: print("run_channels | videos | user ", u) videos = helpers.get_channel_videos(u) print("run_channels | videos | videos", len(videos))