def start_register_4(update, context): query = update.callback_query data = query.data if data[-1] == '1': query.message.edit_reply_markup(reply_markup=None) add_new_channel_db( chnlid=context.user_data['chnlid'], chnlname=context.user_data['chnlusnme'], adminid=query.message.chat.id, descr=context.user_data['descr'], memcount=context.user_data['memcount'], ingroup=context.user_data['grpid'], url=f'https://t.me/{context.user_data["chnlusnme"][1:]}') query.message.reply_text('Your channel has been successfully added') context.bot.send_message( text=f"{e_trophy} Channel Submitted Successfully {e_trophy} " f"\n{context.user_data['to_send']}", chat_id=context.user_data['grpid'], parse_mode=ParseMode.MARKDOWN, disable_notification=True, disable_web_page_preview=True) return cancel(update, context) else: query.message.edit_reply_markup(reply_markup=None) update.effective_message.reply_text( 'Ohk! You have cancelled the submission.' '\n\nTo register again, open the register link from the group') return ConversationHandler.END
def final_pre(update, context): context.user_data['pre3_url'] = update.message.text.strip() if not context.user_data['pre3_url'].startswith('http') and not context.user_data['pre3_url'].startswith('t.me') : update.message.reply_text('Only LINKS allowed') return insert_premium_chnls_db(adminid = update.message.chat_id, user_data = context.user_data, num = 3) update.message.reply_text('Premium-3 channel inserted successfully') update.message.reply_text('Premium Channels have been added successfully\n' '\nIf you wanna change anything, you have to do it before scheduling lists') return cancel(update, context)
def get_pre2_text(update, context): context.user_data['pre1_url'] = update.message.text.strip() if not context.user_data['pre1_url'].startswith('http') and not context.user_data['pre1_url'].startswith('t.me'): update.message.reply_text('Only LINKS allowed') return PRE1_URL insert_premium_chnls_db(adminid = update.message.chat_id, user_data = context.user_data, num = 1) update.message.reply_text('Premium-1 channel inserted successfully') if update.message.chat_id in get_admins_list(context): update.message.reply_text("I'm sorry,you can't add anymore premium channels") update.message.reply_text("Buy premium to activate 2 more slots") return cancel(update, context) update.message.reply_text('Send the text of the Premium-2 Channel') return PRE2_TEXT
def footurl(update, context): user_data = context.user_data try: for i in update.message.text: if i in '()[]': raise ValidationError('Sorry, your text contains restricted letters -> ()[]') dictt = update.message.parse_entities(MessageEntity.ALL_TYPES) for key in dictt.keys(): if key.type == 'url': user_data['url'] = dictt[key] break if 'url' not in user_data: raise ValidationError('URL not found') update_grp = True if not user_data.get('edit', 0): update_grp = None append_grps(user_data['group'], context = context) update_groups_db(adminid=update.message.chat.id, groups=user_data['group'], header=user_data['header'], name=user_data['title'], foot_text=user_data['text'], foot_url=user_data['url'], update = update_grp) log_this(f'AdminID :: {update.message.chat.id}' f"\nHeader :: {user_data['header']}" f"\nFooter :: {user_data['text']}" f"\nURL :: {user_data['url']}") if user_data.get('edit', None): update.message.reply_text('Footer edited successfully') del user_data['edit'] return cancel(update, context) update.message.reply_text('Footer added successfully') #update.message.reply_text('Next Group') return cancel(update, context) except ValidationError as f: update.message.reply_text(f'Error :: {f}') except Exception as e: update.message.reply_text(f'{e_confused}\n{e}')
def start_all_ck(update, context): if update.message.chat.type == 'supergroup': update.message.reply_text( f'{context.bot.link}?start={update.message.chat.id}') return -1 elif context.args and context.args[0]: try: context.user_data['grpid'] = int(context.args[0]) grpinfo = get_groupinfo_db(context.user_data['grpid']) context.user_data['grpname'] = grpinfo.get('name') context.user_data['promochnid'] = grpinfo.get('channel id') except: update.message.reply_text('Invalid Link') return cancel(update, context) my_chnls = get_chnl_db(chanid=context.user_data['promochnid'], adminid=update.message.chat.id) chnl_btn = [] for chnl in my_chnls: chnl_btn.append([ InlineKeyboardButton(f"{chnl['name']}", callback_data=f"c_{chnl['_id']}") ]) chnl_btn.append( [InlineKeyboardButton("Add New Channel", callback_data="new")]) update.message.reply_text("Select an option,", reply_markup=InlineKeyboardMarkup(chnl_btn)) return CHANNEL else: if update.effective_user.id in get_admins_list(context): update.effective_message.reply_text( f"Hey there, {update.effective_user.first_name}", reply_markup=kb_admins_markup) else: update.effective_message.reply_text( f"Hey there, {update.effective_user.first_name}", reply_markup=kbmenu_default_markup)