def new_fed(bot: Bot, update: Update, args: List[str]): if len(args) >= 1: chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] fed_id = key_gen() fed_name = args[0] # Hardcoded fed_id's if fed_name == "OrangeFox/YanaBot-Official": fed_id = "Orang30fficialFed" elif fed_name == "crDroid": fed_id = "crDr0id0fficialFed" # if not sql.search_fed_by_name(fed_name) == False: update.effective_message.reply_text( tld( chat.id, "Federation already exists with this name, Please change name!" )) return print(fed_id) sql.new_fed(user.id, fed_name, fed_id) update.effective_message.reply_text("*Successfully created federation!*"\ "\nName: `{}`"\ "\nID: `{}`" "\n\nUse id to join the federation:" "\n`/joinfed {}`".format(fed_name, fed_id, fed_id), parse_mode=ParseMode.MARKDOWN) else: update.effective_message.reply_text( tld(chat.id, "Please write federation name!"))
def new_fed(bot: Bot, update: Update): chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message fednam = message.text[len('/newfed '):] if not fednam == '': fed_id = str(uuid.uuid4()) fed_name = fednam LOGGER.info(fed_id) #if fednam == 'Name': # fed_id = "Name" x = sql.new_fed(user.id, fed_name, fed_id) if not x: update.effective_message.reply_text( tld( chat.id, "Big F! There is an error while creating Federations, Kindly get into my support group and ask what is going on!" )) return update.effective_message.reply_text("*You have successfully created a new federation!*"\ "\nName: `{}`"\ "\nID: `{}`" "\n\nUse command below to join the federation:" "\n`/joinfed {}`".format(fed_name, fed_id, fed_id), parse_mode=ParseMode.MARKDOWN) bot.send_message( MESSAGE_DUMP, "Federation <b>{}</b> has been created with ID: <pre>{}</pre>". format(fed_name, fed_id), parse_mode=ParseMode.HTML) else: update.effective_message.reply_text( tld(chat.id, "Please write federation name!"))
def new_fed(bot: Bot, update: Update): chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message if chat.type != "private": update.effective_message.reply_text("Please run this command in my PM only!") return fednam = message.text.split(None, 1)[1] if not fednam == '': fed_id = str(uuid.uuid4()) fed_name = fednam LOGGER.info(fed_id) if user.id == int(OWNER_ID): fed_id = fed_name x = sql.new_fed(user.id, fed_name, fed_id) if not x: update.effective_message.reply_text("Failed to create federation! Head over to @tohsakas to notify us of the error.") return update.effective_message.reply_text("*You have successfully created a new federation!*"\ "\nName: `{}`"\ "\nID: `{}`" "\n\nUse the command below to join the federation:" "\n`/joinfed {}`".format(fed_name, fed_id, fed_id), parse_mode=ParseMode.MARKDOWN) try: bot.send_message(MESSAGE_DUMP, "Federation <b>{}</b> has been created with ID: <pre>{}</pre>".format(fed_name, fed_id), parse_mode=ParseMode.HTML) except: LOGGER.warning("Cannot send a message to MESSAGE_DUMP") else: update.effective_message.reply_text("Please give a name for the federation.")
def new_fed(bot: Bot, update: Update, args: List[str]): if len(args) >= 1: chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] fed_id = key_gen() fed_name = args[0] if not sql.search_fed_by_name(fed_name) == False: update.effective_message.reply_text( tld(chat.id, "Already exists federation with this name, change name!")) return print(fed_id) sql.new_fed(user.id, fed_name, fed_id) update.effective_message.reply_text("*Created federation!*"\ "\nName: `{}`"\ "\nID: `{}`" "\n\nUse id to join the federation:" "\n`/joinfed {}`".format(fed_name, fed_id, fed_id), parse_mode=ParseMode.MARKDOWN) else: update.effective_message.reply_text( tld(chat.id, "Please write federation name!"))
def new_fed(bot: Bot, update: Update): spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id) if spam == True: return update.effective_message.reply_text("Spammer detected! Ignoring user.") chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message if chat.type != "private": update.effective_message.reply_text("Make your federation in my PM, not in a group.") return fednam = message.text.split(None, 1)[1] if not fednam == '': fed_id = str(uuid.uuid4()) fed_name = fednam LOGGER.info(fed_id) # Currently only for creator #if fednam == 'Team Nusantara Disciplinary Circle': #fed_id = "TeamNusantaraDevs" x = sql.new_fed(user.id, fed_name, fed_id) if not x: update.effective_message.reply_text("Can't federate! Please contact my maker if the problem still persists.") return update.effective_message.reply_text("*You have succeeded in creating a new federation!*"\ "\nName: `{}`"\ "\nID: `{}`" "\n\nUse the command below to join the federation:" "\n`/joinfed {}`".format(fed_name, fed_id, fed_id), parse_mode=ParseMode.MARKDOWN) try: bot.send_message(GBAN_LOGS, "Federation <b>{}</b> has been created with ID: <pre>{}</pre>".format(fed_name, fed_id), parse_mode=ParseMode.HTML) except: LOGGER.warning("Cannot send a message to GBAN_LOGS") else: update.effective_message.reply_text("Please write down the name of the federation")