コード例 #1
0
ファイル: feds.py プロジェクト: shreyansh000/Userbot
def new_fed(bot: Bot, update: Update, args: List[str]):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    if len(args) >= 1:
        fed_id = str(uuid.uuid4())
        fed_name = args[0]

        #if sql.search_fed_by_name(fed_name):
        #    update.effective_message.reply_text(tld(chat.id, "There is existing federation with this name, change name!"))
        #    return

        print(fed_id)
        sql.new_fed(user.id, fed_name, fed_id)
        update.effective_message.reply_text("*You have successfully created a new federation!*"\
                        "\nName: `{}`"\
                        "\nID: `{}`"
                        "\n\nUse the below command 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> have 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!"))
コード例 #2
0
def new_fed(bot: Bot, update: Update):
    chat = update.effective_chat
    user = update.effective_user
    message = update.effective_message
    if chat.type != "private":
        update.effective_message.reply_text(tld(chat.id, "common_cmd_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(
                tld(chat.id, "feds_create_fail"))
            return

        update.effective_message.reply_text(tld(chat.id,
                                                "feds_create_success").format(
                                                    fed_name, fed_id, fed_id),
                                            parse_mode=ParseMode.MARKDOWN)
        try:
            bot.send_message(MESSAGE_DUMP,
                             tld(chat.id, "feds_create_success_logger").format(
                                 fed_name, fed_id),
                             parse_mode=ParseMode.HTML)
        except Exception:
            LOGGER.warning("Cannot send a message to MESSAGE_DUMP")
    else:
        update.effective_message.reply_text(tld(chat.id, "feds_err_no_args"))
コード例 #3
0
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!"))
コード例 #4
0
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("Do it in PM?")
		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("Federation creation failed! Keep in the mind that this rarely happened! Ask in @HarukaAyaGroup for help!")
			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> have 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 write down the name of the federation")