예제 #1
0
def start(update, context):
    if update.effective_chat.type == "private":
        args = context.args
        if len(args) >= 1:
            if args[0].lower() == "help":
                send_help(update.effective_chat.id, tl(update.effective_message, HELP_STRINGS))

            elif args[0].lower() == "get_notes":
                update.effective_message.reply_text(tl(update.effective_message, "Anda sekarang dapat mengambil catatan di grup."))

            elif args[0].lower().startswith("stngs_"):
                match = re.match("stngs_(.*)", args[0].lower())
                chat = dispatcher.bot.getChat(match.group(1))

                if is_user_admin(chat, update.effective_user.id):
                    send_settings(match.group(1), update.effective_user.id, False)
                else:
                    send_settings(match.group(1), update.effective_user.id, True)

            elif args[0][1:].isdigit() and "rules" in IMPORTED:
                IMPORTED["rules"].send_rules(update, args[0], from_pm=True)

            elif args[0][:4] == "wiki":
                wiki = args[0].split("-")[1].replace('_', ' ')
                message = update.effective_message
                getlang = langsql.get_lang(message)
                if getlang == "id":
                    wikipedia.set_lang("id")
                pagewiki = wikipedia.page(wiki)
                judul = pagewiki.title
                summary = pagewiki.summary
                if len(summary) >= 4096:
                    summary = summary[:4000]+"..."
                message.reply_text("<b>{}</b>\n{}".format(judul, summary), parse_mode=ParseMode.HTML,
                    reply_markup=InlineKeyboardMarkup(
                            [[InlineKeyboardButton(text=tl(update.effective_message, "Baca di Wikipedia"), url=pagewiki.url)]]))

            elif args[0][:6].lower() == "verify":
                chat_id = args[0].split("_")[1]
                verify_welcome(update, context, chat_id)

        else:
            first_name = update.effective_user.first_name
            buttons = InlineKeyboardMarkup(
                [
                [InlineKeyboardButton(text="💭 Language", callback_data="main_setlang"), InlineKeyboardButton(text="⚙️ Connect Group", callback_data="main_connect")],
                [InlineKeyboardButton(text="🏭Hogwarts Group", url="https://t.me/hamione_help"), InlineKeyboardButton(text="admin chat 👩‍💻", url="https://t.me/Matheesha_official_bot")],
                [InlineKeyboardButton(text="❓ Help", url="https://t.me/{}?start=help".format(context.bot.username)), InlineKeyboardButton(text="💖 follow me", url="https://www.instagram.com/mr.matheesha_official?r=nametag")],
                [InlineKeyboardButton(text="🏭Hogwarts Channel", url="https://t.me/{}?startgroup=new".format(context.bot.username))]])
            update.effective_message.reply_photo(DAISY_IMG,
                tl(update.effective_message, PM_START_TEXT).format(escape_markdown(first_name), escape_markdown(context.bot.first_name), OWNER_ID),
                disable_web_page_preview=True,
                parse_mode=ParseMode.MARKDOWN,
                reply_markup=buttons)
    else:
        update.effective_message.reply_text(tl(update.effective_message, "Ada yang bisa saya bantu? 😊"))
예제 #2
0
def set_language(bot, update):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]

    spam = spamfilters(update.effective_message.text,
                       update.effective_message.from_user.id,
                       update.effective_chat.id, update.effective_message)
    if spam == True:
        return

    getlang = sql.get_lang(chat.id)
    if getlang == 'None' or not getlang:
        if msg.from_user.language_code:
            sql.set_lang(msg.chat.id, msg.from_user.language_code)
            getlang = msg.from_user.language_code
        else:
            if msg.chat.type == "private":
                sql.set_lang(msg.chat.id, 'en')
                getlang = 'en'
            else:
                sql.set_lang(msg.chat.id, 'id')
                getlang = 'id'
    loaded_langs = []
    counter = 0

    for x in LOADED_LANGS_ID:
        if counter % 2 == 0:
            loaded_langs.append(
                InlineKeyboardButton(LANGS_TEXT[x],
                                     callback_data="set_lang({})".format(x)))
        else:
            loaded_langs.append(
                InlineKeyboardButton(LANGS_TEXT[x],
                                     callback_data="set_lang({})".format(x)))
        counter += 1

    loaded_langs = list(zip(loaded_langs[::2], loaded_langs[1::2]))

    keyboard = InlineKeyboardMarkup(loaded_langs)

    if chat.title:
        chatname = chat.title
    else:
        if chat.type == "private":
            chatname = user.first_name
        else:
            chatname = tl(update.effective_message, "obrolan saat ini")

    send_message(
        update.effective_message,
        tl(msg,
           "Bahasa di *{}* saat ini adalah:\n{}.\n\nPilih bahasa:").format(
               chatname, LANGS_TEXT[getlang]),
        parse_mode="markdown",
        reply_markup=keyboard)
예제 #3
0
def tl(message, text):
	if type(message) == int or type(message) == str and message[1:].isdigit():
		getlang = sql.get_lang(message)
		if getlang == 'None' or not getlang:
			getlang = 'en'
	else:
		getlang = sql.get_lang(message.chat.id)
		if getlang == 'None' or not getlang:
			if message.from_user.language_code:
				if message.from_user.language_code in LOADED_LANGS_ID:
					sql.set_lang(message.chat.id, message.from_user.language_code)
					getlang = message.from_user.language_code
				else:
					sql.set_lang(message.chat.id, 'en')
					getlang = 'en'
			else:
				sql.set_lang(message.chat.id, 'en')
				getlang = 'en'

	getlangid = {}
	for x in LOADED_LANGS_ID:
		getlangid[x] = x

	if str(getlang) == 'id':
		get = getattr(FUNC_LANG['id'], 'id')
		if text in tuple(get):
			return get.get(text)
		if text in ("RUN_STRINGS", "SLAP_TEMPLATES", "ITEMS", "THROW", "HIT", "RAMALAN_STRINGS", "RAMALAN_FIRST"):
			runstr = getattr(FUNC_LANG['id'], text)
			return runstr
		return text
	elif str(getlang) in LOADED_LANGS_ID:
		func = getattr(FUNC_LANG[getlang], getlang)
		if text in ("RUN_STRINGS", "SLAP_TEMPLATES", "ITEMS", "THROW", "HIT", "RAMALAN_STRINGS", "RAMALAN_FIRST"):
			runstr = getattr(FUNC_LANG[getlang], text)
			return runstr
		langtxt = func.get(text)
		if not langtxt:
			LOGGER.warning("Can't get translated string for lang '{}' ('{}')".format(str(getlang), text))
			langtxt = text
		return langtxt
	else:
		return text
def set_language(update, context):
    msg = update.effective_message  # type: Optional[Message]
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]

    getlang = sql.get_lang(chat.id)
    if getlang == 'None' or not getlang:
        if msg.from_user.language_code:
            sql.set_lang(msg.chat.id, msg.from_user.language_code)
            getlang = msg.from_user.language_code
        else:
            sql.set_lang(msg.chat.id, 'en')
            getlang = 'en'
    loaded_langs = []
    tmp_list = []
    counter = 0

    for x in LOADED_LANGS_ID:
        counter += 1
        tmp_list.append(
            InlineKeyboardButton(LANGS_TEXT[x],
                                 callback_data="set_lang({})".format(x)))
        if counter % 2 == 0:
            loaded_langs.append(tmp_list)
            tmp_list = []
        if counter == len(LOADED_LANGS_ID):
            loaded_langs.append(tmp_list)

    loaded_langs.append([
        InlineKeyboardButton(
            "Translate",
            url=
            "https://github.com/fortifying/fortizerswatcher/blob/master/TRANSLATION.md"
        )
    ])

    keyboard = InlineKeyboardMarkup(loaded_langs)

    if chat.title:
        chatname = chat.title
    else:
        if chat.type == "private":
            chatname = user.first_name
        else:
            chatname = tl(update.effective_message, "obrolan saat ini")

    currlang = LANGS_TEXT[getlang] if LANGS_TEXT.get(
        getlang) else "(Deleted langs)"
    send_message(
        update.effective_message,
        tl(msg,
           "Bahasa di *{}* saat ini adalah:\n{}.\n\nPilih bahasa:").format(
               chatname, currlang),
        parse_mode="markdown",
        reply_markup=keyboard)
예제 #5
0
def start(update, context):
    if update.effective_chat.type == "private":
        args = context.args
        if len(args) >= 1:
            if args[0].lower() == "help":
                send_help(update.effective_chat.id, tl(update.effective_message, HELP_STRINGS))

            elif args[0].lower() == "get_notes":
                update.effective_message.reply_text(tl(update.effective_message, "You can now take notes in groups."))

            elif args[0].lower().startswith("stngs_"):
                match = re.match("stngs_(.*)", args[0].lower())
                chat = dispatcher.bot.getChat(match.group(1))

                if is_user_admin(chat, update.effective_user.id):
                    send_settings(match.group(1), update.effective_user.id, False)
                else:
                    send_settings(match.group(1), update.effective_user.id, True)

            elif args[0][1:].isdigit() and "rules" in IMPORTED:
                IMPORTED["rules"].send_rules(update, args[0], from_pm=True)

            elif args[0][:4] == "wiki":
                wiki = args[0].split("-")[1].replace('_', ' ')
                message = update.effective_message
                getlang = langsql.get_lang(message)
                if getlang == "id":
                    wikipedia.set_lang("id")
                pagewiki = wikipedia.page(wiki)
                judul = pagewiki.title
                summary = pagewiki.summary
                if len(summary) >= 4096:
                    summary = summary[:4000]+"..."
                message.reply_text("<b>{}</b>\n{}".format(judul, summary), parse_mode=ParseMode.HTML,
                    reply_markup=InlineKeyboardMarkup(
                            [[InlineKeyboardButton(text=tl(update.effective_message, "Wikipedia"), url=pagewiki.url)]]))

            elif args[0][:6].lower() == "verify":
                chat_id = args[0].split("_")[1]
                verify_welcome(update, context, chat_id)

        else:
            first_name = update.effective_user.first_name
            buttons = InlineKeyboardMarkup(
                [[InlineKeyboardButton(text="🎉 Add me to your group", url="https://t.me/{}?startgroup=new".format(context.bot.username))],
                [InlineKeyboardButton(text="💭 Language", callback_data="main_setlang"), InlineKeyboardButton(text="⚙️ Connect Group", callback_data="main_connect")],
                [InlineKeyboardButton(text="👥 Support Group", url="https://t.me/cyberwordk"), InlineKeyboardButton(text="🔔 Update Channel", url="https://t.me/snewst")],
                [InlineKeyboardButton(text="❓ Help", url="https://t.me/{}?start=help".format(context.bot.username)), InlineKeyboardButton(text="💖 Donate", url="#")]])
            update.effective_message.reply_text(
                tl(update.effective_message, PM_START_TEXT).format(escape_markdown(first_name), escape_markdown(context.bot.first_name), OWNER_ID),
                disable_web_page_preview=True,
                parse_mode=ParseMode.MARKDOWN,
                reply_markup=buttons)
    else:
        update.effective_message.reply_text(tl(update.effective_message, "Is there anything I can help? 😊"))
예제 #6
0
파일: __main__.py 프로젝트: yupisky/NISA
def start(bot: Bot, update: Update, args: List[str]):
    spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id, update.effective_message)
    if spam == True:
        return
    if update.effective_chat.type == "private":
        if len(args) >= 1:
            if args[0].lower() == "help":
                send_help(update.effective_chat.id, tl(update.effective_message, HELP_STRINGS))

            elif args[0].lower() == "get_notes":
                update.effective_message.reply_text(tl(update.effective_message, "Anda sekarang dapat mengambil catatan di grup."))

            elif args[0].lower().startswith("stngs_"):
                match = re.match("stngs_(.*)", args[0].lower())
                chat = dispatcher.bot.getChat(match.group(1))

                if is_user_admin(chat, update.effective_user.id):
                    send_settings(match.group(1), update.effective_user.id, False)
                else:
                    send_settings(match.group(1), update.effective_user.id, True)

            elif args[0][1:].isdigit() and "rules" in IMPORTED:
                IMPORTED["rules"].send_rules(update, args[0], from_pm=True)

            elif args[0][:4] == "wiki":
                wiki = args[0].split("-")[1].replace('_', ' ')
                message = update.effective_message
                getlang = langsql.get_lang(message)
                if getlang == "id":
                    wikipedia.set_lang("id")
                pagewiki = wikipedia.page(wiki)
                judul = pagewiki.title
                summary = pagewiki.summary
                if len(summary) >= 4096:
                    summary = summary[:4000]+"..."
                message.reply_text("<b>{}</b>\n{}".format(judul, summary), parse_mode=ParseMode.HTML,
                    reply_markup=InlineKeyboardMarkup(
                            [[InlineKeyboardButton(text=tl(update.effective_message, "Baca di Wikipedia"), url=pagewiki.url)]]))

        else:
            first_name = update.effective_user.first_name
            buttons = InlineKeyboardMarkup(
                [[InlineKeyboardButton(text="🎉 Add me to your group", url="https://t.me/NLydW_Bot?startgroup=new")],
                [InlineKeyboardButton(text="💭 Language", callback_data="main_setlang"), InlineKeyboardButton(text="⚙️ Connect Group", callback_data="main_connect")],
                [InlineKeyboardButton(text="👥 Support Group", url="https://t.me/joinchat/RNFD7UXOd8uG0B_0MCEzeA"), InlineKeyboardButton(text="🔔 Update Channel", url="https://t.me/GROUPSKEMER")],
                [InlineKeyboardButton(text="❓ Help", url="https://t.me/NLydW_Bot?start=help"), InlineKeyboardButton(text="💖 Donate", url="http://paypal.me/AIrvandi")]])
            update.effective_message.reply_text(
                tl(update.effective_message, PM_START_TEXT).format(escape_markdown(first_name), escape_markdown(bot.first_name), OWNER_ID),
                disable_web_page_preview=True,
                parse_mode=ParseMode.MARKDOWN,
                reply_markup=buttons)
    else:
        update.effective_message.reply_text(tl(update.effective_message, "Ada yang bisa saya bantu? 😊"))
예제 #7
0
def start(bot: Bot, update: Update, args: List[str]):
    spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id, update.effective_message)
    if spam == True:
        return
    if update.effective_chat.type == "private":
        if len(args) >= 1:
            if args[0].lower() == "help":
                send_help(update.effective_chat.id, tl(update.effective_message, HELP_STRINGS))

            elif args[0].lower() == "get_notes":
                update.effective_message.reply_text(tl(update.effective_message, "Anda sekarang dapat mengambil catatan di grup."))

            elif args[0].lower().startswith("stngs_"):
                match = re.match("stngs_(.*)", args[0].lower())
                chat = dispatcher.bot.getChat(match.group(1))

                if is_user_admin(chat, update.effective_user.id):
                    send_settings(match.group(1), update.effective_user.id, False)
                else:
                    send_settings(match.group(1), update.effective_user.id, True)

            elif args[0][1:].isdigit() and "rules" in IMPORTED:
                IMPORTED["rules"].send_rules(update, args[0], from_pm=True)

            elif args[0][:4] == "wiki":
                wiki = args[0].split("-")[1].replace('_', ' ')
                message = update.effective_message
                getlang = langsql.get_lang(message)
                if getlang == "id":
                    wikipedia.set_lang("id")
                pagewiki = wikipedia.page(wiki)
                judul = pagewiki.title
                summary = pagewiki.summary
                if len(summary) >= 4096:
                    summary = summary[:4000]+"..."
                message.reply_text("<b>{}</b>\n{}".format(judul, summary), parse_mode=ParseMode.HTML,
                    reply_markup=InlineKeyboardMarkup(
                            [[InlineKeyboardButton(text=tl(update.effective_message, "Baca di Wikipedia"), url=pagewiki.url)]]))

        else:
            first_name = update.effective_user.first_name
            buttons = InlineKeyboardMarkup(
                [[InlineKeyboardButton(text="🎉 Tambahkan ke Grup", url="https://t.me/Balqissbot?startgroup=new")],
                [InlineKeyboardButton(text="💭 Bahasa", callback_data="main_setlang"), InlineKeyboardButton(text="⚙️ Hubungkan Grup", callback_data="main_connect")],
                [InlineKeyboardButton(text="👥 Grup Pendukung", url="https://t.me/Balqisdiskussi"), InlineKeyboardButton(text="🔔 Update Channel", url="https://t.me/balqisupdate")],
                [InlineKeyboardButton(text="❓ Bantuan", url="https://t.me/Balqissbot?start=help"), InlineKeyboardButton(text="🤑 Donasi", url="https://t.me/SquidwardTentacles0")]])
            update.effective_message.reply_text(
                tl(update.effective_message, PM_START_TEXT).format(escape_markdown(first_name), escape_markdown(bot.first_name), OWNER_ID),
                disable_web_page_preview=True,
                parse_mode=ParseMode.MARKDOWN,
                reply_markup=buttons)
    else:
        update.effective_message.reply_text(tl(update.effective_message, "Ada yang bisa Balqis bantu sayang😘 ?"))
예제 #8
0
def wiki(bot: Bot, update: Update):
	spam = spamfilters(update.effective_message.text, update.effective_message.from_user.id, update.effective_chat.id, update.effective_message)
	if spam == True:
		return
	msg = update.effective_message
	chat_id = update.effective_chat.id
	args = update.effective_message.text.split(None, 1)
	teks = args[1]
	message = update.effective_message
	getlang = langsql.get_lang(chat_id)
	if str(getlang) == "id":
		wikipedia.set_lang("id")
	else:
		wikipedia.set_lang("en")
	try:
		pagewiki = wikipedia.page(teks)
	except wikipedia.exceptions.PageError:
		send_message(update.effective_message, tl(update.effective_message, "Hasil tidak ditemukan"))
		return
	except wikipedia.exceptions.DisambiguationError as refer:
		rujuk = str(refer).split("\n")
		if len(rujuk) >= 6:
			batas = 6
		else:
			batas = len(rujuk)
		teks = ""
		for x in range(batas):
			if x == 0:
				if getlang == "id":
					teks += rujuk[x].replace('may refer to', 'dapat merujuk ke')+"\n"
				else:
					teks += rujuk[x]+"\n"
			else:
				teks += "- `"+rujuk[x]+"`\n"
		send_message(update.effective_message, teks, parse_mode="markdown")
		return
	except IndexError:
		send_message(update.effective_message, tl(update.effective_message, "Tulis pesan untuk mencari dari sumber wikipedia"))
		return
	judul = pagewiki.title
	summary = pagewiki.summary
	if update.effective_message.chat.type == "private":
		send_message(update.effective_message, tl(update.effective_message, "Hasil dari {} adalah:\n\n<b>{}</b>\n{}").format(teks, judul, summary), parse_mode=ParseMode.HTML)
	else:
		if len(summary) >= 200:
			judul = pagewiki.title
			summary = summary[:200]+"..."
			button = InlineKeyboardMarkup([[InlineKeyboardButton(text=tl(update.effective_message, "Baca Lebih Lengkap"), url="t.me/{}?start=wiki-{}".format(bot.username, teks.replace(' ', '_')))]])
		else:
			button = None
		send_message(update.effective_message, tl(update.effective_message, "Hasil dari {} adalah:\n\n<b>{}</b>\n{}").format(teks, judul, summary), parse_mode=ParseMode.HTML, reply_markup=button)
예제 #9
0
def get_time_alt(bot: Bot, update: Update, args: List[str]):
    spam = spamfilters(update.effective_message.text,
                       update.effective_message.from_user.id,
                       update.effective_chat.id, update.effective_message)
    if spam == True:
        return
    if args:
        location = " ".join(args)
        if location.lower() == bot.first_name.lower():
            send_message(update.effective_message,
                         "Selalu ada waktu banned untukku!")
            bot.send_sticker(update.effective_chat.id, BAN_STICKER)
            return

        res = requests.get(
            'https://dev.virtualearth.net/REST/v1/timezone/?query={}&key={}'.
            format(location, MAPS_API))

        if res.status_code == 200:
            loc = res.json()
            if len(loc['resourceSets'][0]['resources'][0]
                   ['timeZoneAtLocation']) == 0:
                send_message(
                    update.effective_message,
                    tl(update.effective_message, "Lokasi tidak di temukan!"))
                return
            placename = loc['resourceSets'][0]['resources'][0][
                'timeZoneAtLocation'][0]['placeName']
            localtime = loc['resourceSets'][0]['resources'][0][
                'timeZoneAtLocation'][0]['timeZone'][0]['convertedTime'][
                    'localTime']
            if lang_sql.get_lang(update.effective_chat.id) == "id":
                locale.setlocale(locale.LC_TIME, 'id_ID.UTF-8')
                time = datetime.strptime(
                    localtime,
                    '%Y-%m-%dT%H:%M:%S').strftime("%H:%M:%S hari %A, %d %B")
            else:
                time = datetime.strptime(
                    localtime,
                    '%Y-%m-%dT%H:%M:%S').strftime("%H:%M:%S %A, %d %B")
            send_message(update.effective_message,
                         tl(update.effective_message,
                            "Sekarang pukul `{}` di `{}`").format(
                                time, placename),
                         parse_mode="markdown")
    else:
        send_message(update.effective_message,
                     tl(update.effective_message,
                        "Gunakan `/time nama daerah`\nMisal: `/time jakarta`"),
                     parse_mode="markdown")
예제 #10
0
def terjemah(update, context):
	msg = update.effective_message
	chat_id = update.effective_chat.id
	getlang = langsql.get_lang(update.effective_message.from_user.id)
	try:
		if msg.reply_to_message and msg.reply_to_message.text:
			args = update.effective_message.text.split()
			if len(args) >= 2:
				target = args[1]
				if "-" in target:
					target2 = target.split("-")[1]
					target = target.split("-")[0]
				else:
					target2 = None
			else:
				if getlang:
					target = getlang
					target2 = None
				else:
					raise IndexError
			teks = msg.reply_to_message.text
			#teks = deEmojify(teks)
			exclude_list = UNICODE_EMOJI.keys()
			for emoji in exclude_list:
				if emoji in teks:
					teks = teks.replace(emoji, '')
			message = update.effective_message
			trl = Translator()
			if target2 == None:
				deteksibahasa = trl.detect(teks)
				tekstr = trl.translate(teks, dest=target)
				send_message(update.effective_message, tl(update.effective_message, "Diterjemahkan dari `{}` ke `{}`:\n`{}`").format(deteksibahasa.lang, target, tekstr.text), parse_mode=ParseMode.MARKDOWN)
			else:
				tekstr = trl.translate(teks, dest=target2, src=target)
				send_message(update.effective_message, tl(update.effective_message, "Diterjemahkan dari `{}` ke `{}`:\n`{}`").format(target, target2, tekstr.text), parse_mode=ParseMode.MARKDOWN)
			
		else:
			args = update.effective_message.text.split(None, 2)
			if len(args) != 1:
				target = args[1]
				teks = args[2]
				target2 = None
				if "-" in target:
					target2 = target.split("-")[1]
					target = target.split("-")[0]
			else:
				target = getlang
				teks = args[1]
			#teks = deEmojify(teks)
			exclude_list = UNICODE_EMOJI.keys()
			for emoji in exclude_list:
				if emoji in teks:
					teks = teks.replace(emoji, '')
			message = update.effective_message
			trl = Translator()
			if target2 == None:
				deteksibahasa = trl.detect(teks)
				tekstr = trl.translate(teks, dest=target)
				return send_message(update.effective_message, tl(update.effective_message, "Diterjemahkan dari `{}` ke `{}`:\n`{}`").format(deteksibahasa.lang, target, tekstr.text), parse_mode=ParseMode.MARKDOWN)
			else:
				tekstr = trl.translate(teks, dest=target2, src=target)
				send_message(update.effective_message, tl(update.effective_message, "Diterjemahkan dari `{}` ke `{}`:\n`{}`").format(target, target2, tekstr.text), parse_mode=ParseMode.MARKDOWN)
	except IndexError:
		send_message(update.effective_message, tl(update.effective_message, "Balas pesan atau tulis pesan dari bahasa lain untuk "
											"diterjemahkan kedalam bahasa yang di dituju\n\n"
											"Contoh: `/tr en-id` untuk menerjemahkan dari Bahasa inggris ke Bahasa Indonesia\n"
											"Atau gunakan: `/tr id` untuk deteksi otomatis dan menerjemahkannya kedalam bahasa indonesia"), parse_mode="markdown")
	except ValueError:
		send_message(update.effective_message, tl(update.effective_message, "Bahasa yang di tuju tidak ditemukan!"))
	else:
		return
예제 #11
0
def export_data(update, context):
	msg = update.effective_message  # type: Optional[Message]
	user = update.effective_user  # type: Optional[User]

	chat_id = update.effective_chat.id
	chat = update.effective_chat
	current_chat_id = update.effective_chat.id
	chat_data = context.chat_data

	conn = connected(context.bot, update, chat, user.id, need_admin=True)
	if conn:
		chat = dispatcher.bot.getChat(conn)
		chat_id = conn
		chat_name = dispatcher.bot.getChat(conn).title
	else:
		if update.effective_message.chat.type == "private":
			send_message(update.effective_message, tl(update.effective_message, "Anda bisa lakukan command ini pada grup, bukan pada PM"))
			return ""
		chat = update.effective_chat
		chat_id = update.effective_chat.id
		chat_name = update.effective_message.chat.title

	jam = time.time()
	new_jam = jam + 43200
	cek = get_chat(chat_id, chat_data)
	if cek.get('status'):
		if jam <= int(cek.get('value')):
			waktu = time.strftime("%H:%M:%S %d/%m/%Y", time.localtime(cek.get('value')))
			send_message(update.effective_message, tl(update.effective_message, "Anda dapat mencadangan data sekali dalam 12 jam!\n[Orang ini](tg://user?id={}) sudah mencadangan data\nAnda dapat mencadangan data lagi pada `{}`").format(cek.get('user'), waktu), parse_mode=ParseMode.MARKDOWN)
			return
		else:
			if user.id != OWNER_ID:
				put_chat(chat_id, user.id, new_jam, chat_data)
	else:
		if user.id != OWNER_ID:
			put_chat(chat_id, user.id, new_jam, chat_data)


	# Backup version
	# Revision: 07/07/2019
	backup_ver = 1
	bot_base = "Emilia"

	# Make sure this backup is for this bot
	bot_id = context.bot.id

	# Backuping antiflood
	flood_mode, flood_duration = antifloodsql.get_flood_setting(chat_id)
	flood_limit = antifloodsql.get_flood_limit(chat_id)
	antiflood = {'flood_mode': flood_mode, 'flood_duration': flood_duration, 'flood_limit': flood_limit}

	# Backuping blacklists
	all_blacklisted = blacklistsql.get_chat_blacklist(chat_id)
	blacklist_mode, blacklist_duration = blacklistsql.get_blacklist_setting(chat.id)
	blacklists = {'blacklist_mode': blacklist_mode, 'blacklist_duration': blacklist_duration, 'blacklists': all_blacklisted}

	# Backuping blacklists sticker
	all_blsticker = blackliststksql.get_chat_stickers(chat_id)
	blsticker_mode, blsticker_duration = blacklistsql.get_blacklist_setting(chat.id)
	blstickers = {'blsticker_mode': blsticker_mode, 'blsticker_duration': blsticker_duration, 'blstickers': all_blsticker}

	# Backuping disabled
	cmd_disabled = disabledsql.get_all_disabled(chat_id)
	disabled = {'disabled': cmd_disabled}

	# Backuping filters
	all_filters = filtersql.get_chat_triggers(chat_id)
	filters_gen = []
	for x in all_filters:
		filt = filtersql.get_filter(chat.id, x)
		if filt.is_sticker:
			filt_type = 1
		elif filt.is_document:
			filt_type = 2
		elif filt.is_image:
			filt_type = 3
		elif filt.is_audio:
			filt_type = 4
		elif filt.is_voice:
			filt_type = 5
		elif filt.is_video:
			filt_type = 6
		elif filt.has_markdown:
			filt_type = 0
		else:
			filt_type = 7
		filters_gen.append({"name": x, "reply": filt.reply, "type": filt_type})
	filters = {'filters': filters_gen}

	# Backuping greetings msg and config
	greetings = {}
	pref, welcome_m, cust_content, welcome_type = welcsql.get_welc_pref(chat_id)
	if not welcome_m:
		welcome_m = ""
	if not cust_content:
		cust_content = ""
	buttons = welcsql.get_welc_buttons(chat_id)
	welcome_m += revert_buttons(buttons)
	greetings["welcome"] = {"enable": pref, "text": welcome_m, "content": cust_content, "type": welcome_type}

	pref, goodbye_m, cust_content, goodbye_type = welcsql.get_gdbye_pref(chat_id)
	if not goodbye_m:
		goodbye_m = ""
	if not cust_content:
		cust_content = ""
	buttons = welcsql.get_gdbye_buttons(chat_id)
	goodbye_m += revert_buttons(buttons)
	greetings["goodbye"] = {"enable": pref, "text": goodbye_m, "content": cust_content, "type": goodbye_type}

	curr = welcsql.clean_service(chat_id)
	greetings["clean_service"] = curr

	getcur, cur_value, extra_verify, timeout, timeout_mode, cust_text = welcsql.welcome_security(chat_id)
	greetings["security"] = {"enable": getcur, "text": cust_text, "time": cur_value, "extra_verify": extra_verify, "timeout": timeout, "timeout_mode": timeout_mode}

	# Backuping chat language
	getlang = langsql.get_lang(chat_id)
	language = {"language": getlang}

	# Backuping locks
	curr_locks = locksql.get_locks(chat_id)
	curr_restr = locksql.get_restr(chat_id)

	if curr_locks:
		locked_lock = {
			"sticker": curr_locks.sticker,
			"audio": curr_locks.audio,
			"voice": curr_locks.voice,
			"document": curr_locks.document,
			"video": curr_locks.video,
			"contact": curr_locks.contact,
			"photo": curr_locks.photo,
			"gif": curr_locks.gif,
			"url": curr_locks.url,
			"bots": curr_locks.bots,
			"forward": curr_locks.forward,
			"game": curr_locks.game,
			"location": curr_locks.location,
			"rtl": curr_locks.rtl
		}
	else:
		locked_lock = {}

	if curr_restr:
		locked_restr = {
			"messages": curr_restr.messages,
			"media": curr_restr.media,
			"other": curr_restr.other,
			"previews": curr_restr.preview,
			"all": all([curr_restr.messages, curr_restr.media, curr_restr.other, curr_restr.preview])
		}
	else:
		locked_restr = {}

	lock_warn = locksql.get_lockconf(chat_id)

	locks = {'lock_warn': lock_warn, 'locks': locked_lock, 'restrict': locked_restr}

	# Backuping notes
	note_list = notesql.get_all_chat_notes(chat_id)
	notes = []
	for note in note_list:
		buttonlist = ""
		note_tag = note.name
		note_type = note.msgtype
		getnote = notesql.get_note(chat_id, note.name)
		if not note.value:
			note_data = ""
		else:
			tombol = notesql.get_buttons(chat_id, note_tag)
			keyb = []
			buttonlist = ""
			for btn in tombol:
				if btn.same_line:
					buttonlist += "[{}](buttonurl:{}:same)\n".format(btn.name, btn.url)
				else:
					buttonlist += "[{}](buttonurl:{})\n".format(btn.name, btn.url)
			note_data = "{}\n\n{}".format(note.value, buttonlist)
		note_file = note.file
		if not note_file:
			note_file = ""
		notes.append({"note_tag": note_tag, "note_data": note_data, "note_file": note_file, "note_type": note_type})

	# Backuping reports
	get_report = reportsql.user_should_report(chat_id)
	report = {'report': get_report}

	# Backuping rules
	getrules = rulessql.get_rules(chat_id)
	rules = {"rules": getrules}

	# Backuping warns config and warn filters
	warn_limit, _, warn_mode = warnssql.get_warn_setting(chat_id)
	all_handlers = warnssql.get_chat_warn_triggers(chat_id)
	all_warn_filter = []
	for x in all_handlers:
		warnreply = warnssql.get_warn_filter(chat_id, x)
		all_warn_filter.append({'name': x, 'reason': warnreply.reply})
	if not warn_mode:
		warn_mode = ""
	# Get all warnings in current chat
	allwarns = warnssql.get_allwarns(chat_id)
	warns = {"warn_limit": warn_limit, "warn_mode": warn_mode, "warn_filters": all_warn_filter, "chat_warns": allwarns}


	# Parsing backups
	backup = {"bot_id": bot_id, "bot_base": bot_base, "antiflood": antiflood, "blacklists": blacklists, "blstickers": blstickers, "disabled": disabled, "filters": filters, "greetings": greetings, "language": language, "locks": locks, "notes": notes, "report": report, "rules": rules, "warns": warns, "version": backup_ver}


	all_backups = json.dumps(backup, indent=4, cls=SetEncoder)
	f = open("{}-Emilia.backup".format(chat_id), "w")
	f.write(str(all_backups))
	f.close()
	context.bot.sendChatAction(current_chat_id, "upload_document")
	tgl = time.strftime("%H:%M:%S - %d/%m/%Y", time.localtime(time.time()))
	try:
		context.bot.sendMessage(TEMPORARY_DATA, "*Berhasil mencadangan untuk:*\nNama chat: `{}`\nID chat: `{}`\nPada: `{}`".format(chat.title, chat_id, tgl), parse_mode=ParseMode.MARKDOWN)
	except BadRequest:
		pass
	send = context.bot.sendDocument(current_chat_id, document=open('{}-Emilia.backup'.format(chat_id), 'rb'), caption=tl(update.effective_message, "*Berhasil mencadangan untuk:*\nNama chat: `{}`\nID chat: `{}`\nPada: `{}`\n\nNote: cadangan ini khusus untuk bot ini, jika di import ke bot lain maka catatan dokumen, video, audio, voice, dan lain-lain akan hilang").format(chat.title, chat_id, tgl), timeout=360, reply_to_message_id=msg.message_id, parse_mode=ParseMode.MARKDOWN)
	try:
		# Send to temp data for prevent unexpected issue
		context.bot.sendDocument(TEMPORARY_DATA, document=send.document.file_id, caption=tl(update.effective_message, "*Berhasil mencadangan untuk:*\nNama chat: `{}`\nID chat: `{}`\nPada: `{}`\n\nNote: cadangan ini khusus untuk bot ini, jika di import ke bot lain maka catatan dokumen, video, audio, voice, dan lain-lain akan hilang").format(chat.title, chat_id, tgl), timeout=360, parse_mode=ParseMode.MARKDOWN)
	except BadRequest:
		pass
	os.remove("{}-Emilia.backup".format(chat_id)) # Cleaning file
예제 #12
0
def start(update, context):
    if update.effective_chat.type == "private":
        args = context.args
        if len(args) >= 1:
            if args[0].lower() == "help":
                send_help(update.effective_chat.id,
                          tl(update.effective_message, HELP_STRINGS))

            elif args[0].lower() == "get_notes":
                update.effective_message.reply_text(
                    tl(update.effective_message,
                       "Anda sekarang dapat mengambil catatan di grup."))

            elif args[0].lower().startswith("stngs_"):
                match = re.match("stngs_(.*)", args[0].lower())
                chat = dispatcher.bot.getChat(match.group(1))

                if is_user_admin(chat, update.effective_user.id):
                    send_settings(match.group(1), update.effective_user.id,
                                  False)
                else:
                    send_settings(match.group(1), update.effective_user.id,
                                  True)

            elif args[0][1:].isdigit() and "rules" in IMPORTED:
                IMPORTED["rules"].send_rules(update, args[0], from_pm=True)

            elif args[0][:4] == "wiki":
                wiki = args[0].split("-")[1].replace('_', ' ')
                message = update.effective_message
                getlang = langsql.get_lang(message)
                if getlang == "id":
                    wikipedia.set_lang("id")
                pagewiki = wikipedia.page(wiki)
                judul = pagewiki.title
                summary = pagewiki.summary
                if len(summary) >= 4096:
                    summary = summary[:4000] + "..."
                message.reply_text("<b>{}</b>\n{}".format(judul, summary),
                                   parse_mode=ParseMode.HTML,
                                   reply_markup=InlineKeyboardMarkup([[
                                       InlineKeyboardButton(text=tl(
                                           update.effective_message,
                                           "Baca di Wikipedia"),
                                                            url=pagewiki.url)
                                   ]]))

            elif args[0][:6].lower() == "verify":
                chat_id = args[0].split("_")[1]
                verify_welcome(update, context, chat_id)

        else:
            first_name = update.effective_user.first_name
            buttons = InlineKeyboardMarkup(
                [[
                    InlineKeyboardButton(
                        text="👑 Add me to your group",
                        url="https://t.me/{}?startgroup=new".format(
                            context.bot.username))
                ],
                 [
                     InlineKeyboardButton(text="💭 Language",
                                          callback_data="main_setlang"),
                     InlineKeyboardButton(text="⚙️ Connect Group",
                                          callback_data="main_connect")
                 ],
                 [
                     InlineKeyboardButton(text="👥 Support Group",
                                          url="http://t.me/notimetosleep1"),
                     InlineKeyboardButton(text="🌐 Support Channel",
                                          url="https://t.me/nttschennel")
                 ],
                 [
                     InlineKeyboardButton(
                         text="❓ Help",
                         url="https://t.me/{}?start=help".format(
                             context.bot.username)),
                     InlineKeyboardButton(
                         text="👻 Profil CESPER",
                         url="https://id.m.wikipedia.org/wiki/Casper_(film)")
                 ]])
            update.effective_message.reply_photo(
                "https://i.ibb.co/F3MnkFd/IMG-20210123-174846-513.jpg",
                tl(update.effective_message, PM_START_TEXT).format(
                    escape_markdown(first_name),
                    escape_markdown(context.bot.first_name), OWNER_ID),
                disable_web_page_preview=True,
                parse_mode=ParseMode.MARKDOWN,
                reply_markup=buttons)
    else:
        update.effective_message.reply_text(
            tl(update.effective_message, "ADA YANG BISA SAYA KENTOD? 💦"))
예제 #13
0
def start(bot: Bot, update: Update, args: List[str]):
    spam = spamfilters(update.effective_message.text,
                       update.effective_message.from_user.id,
                       update.effective_chat.id, update.effective_message)
    if spam == True:
        return
    if update.effective_chat.type == "private":
        if len(args) >= 1:
            if args[0].lower() == "help":
                send_help(update.effective_chat.id,
                          tl(update.effective_message, HELP_STRINGS))

            elif args[0].lower() == "get_notes":
                update.effective_message.reply_text(
                    tl(update.effective_message,
                       "Anda sekarang dapat mengambil catatan di grup."))

            elif args[0].lower().startswith("stngs_"):
                match = re.match("stngs_(.*)", args[0].lower())
                chat = dispatcher.bot.getChat(match.group(1))

                if is_user_admin(chat, update.effective_user.id):
                    send_settings(match.group(1), update.effective_user.id,
                                  False)
                else:
                    send_settings(match.group(1), update.effective_user.id,
                                  True)

            elif args[0][1:].isdigit() and "rules" in IMPORTED:
                IMPORTED["rules"].send_rules(update, args[0], from_pm=True)

            elif args[0][:4] == "wiki":
                wiki = args[0].split("-")[1].replace('_', ' ')
                message = update.effective_message
                getlang = langsql.get_lang(message)
                if getlang == "id":
                    wikipedia.set_lang("id")
                pagewiki = wikipedia.page(wiki)
                judul = pagewiki.title
                summary = pagewiki.summary
                if len(summary) >= 4096:
                    summary = summary[:4000] + "..."
                message.reply_text("<b>{}</b>\n{}".format(judul, summary),
                                   parse_mode=ParseMode.HTML,
                                   reply_markup=InlineKeyboardMarkup([[
                                       InlineKeyboardButton(text=tl(
                                           update.effective_message,
                                           "Baca di Wikipedia"),
                                                            url=pagewiki.url)
                                   ]]))

        else:
            first_name = update.effective_user.first_name
            buttons = InlineKeyboardMarkup(
                [[
                    InlineKeyboardButton(
                        text="TAMBAHKAN AKU DIGRUP KAMU DONG! 🧸",
                        url="https://t.me/Naylasilvianibot?startgroup=new")
                ],
                 [
                     InlineKeyboardButton(text="SETELAN BAHASA! 📚",
                                          callback_data="main_setlang"),
                     InlineKeyboardButton(text="KONEKSI GRUP! ⚙️",
                                          callback_data="main_connect")
                 ],
                 [
                     InlineKeyboardButton(text="SUPPORT GRUP! 💊",
                                          url="http://t.me/humangabutguys"),
                     InlineKeyboardButton(text="UPDATE CHANNEL! 💎",
                                          url="https://t.me/captionanakmuda")
                 ],
                 [
                     InlineKeyboardButton(
                         text="PERTOLOGAN! 🛠",
                         url="https://t.me/Naylasilvianibot?start=help"),
                     InlineKeyboardButton(text="DONASI BOT ✨",
                                          url="http://paypal.me/AIrvandi")
                 ]])
            update.effective_message.reply_text(
                tl(update.effective_message,
                   PM_START_TEXT).format(escape_markdown(first_name),
                                         escape_markdown(bot.first_name),
                                         OWNER_ID),
                disable_web_page_preview=True,
                parse_mode=ParseMode.MARKDOWN,
                reply_markup=buttons)
    else:
        update.effective_message.reply_text(
            tl(update.effective_message, "Ada yang bisa saya bantu? 😊"))
예제 #14
0
def start(update, context):
    if update.effective_chat.type == "private":
        args = context.args
        if len(args) >= 1:
            if args[0].lower() == "help":
                send_help(update.effective_chat.id,
                          tl(update.effective_message, HELP_STRINGS))

            elif args[0].lower() == "get_notes":
                update.effective_message.reply_text(
                    tl(update.effective_message,
                       "Now you can get notes in group."))

            elif args[0].lower().startswith("stngs_"):
                match = re.match("stngs_(.*)", args[0].lower())
                chat = dispatcher.bot.getChat(match.group(1))

                if is_user_admin(chat, update.effective_user.id):
                    send_settings(match.group(1), update.effective_user.id,
                                  False)
                else:
                    send_settings(match.group(1), update.effective_user.id,
                                  True)

            elif args[0][1:].isdigit() and "rules" in IMPORTED:
                IMPORTED["rules"].send_rules(update, args[0], from_pm=True)

            elif args[0][:4] == "wiki":
                wiki = args[0].split("-")[1].replace('_', ' ')
                message = update.effective_message
                getlang = langsql.get_lang(message)
                if getlang == "id":
                    wikipedia.set_lang("id")
                pagewiki = wikipedia.page(wiki)
                judul = pagewiki.title
                summary = pagewiki.summary
                if len(summary) >= 4096:
                    summary = summary[:4000] + "..."
                message.reply_text("<b>{}</b>\n{}".format(judul, summary),
                                   parse_mode=ParseMode.HTML,
                                   reply_markup=InlineKeyboardMarkup([[
                                       InlineKeyboardButton(text=tl(
                                           update.effective_message,
                                           "Read on Wikipedia"),
                                                            url=pagewiki.url)
                                   ]]))

            elif args[0][:6].lower() == "verify":
                chat_id = args[0].split("_")[1]
                verify_welcome(update, context, chat_id)

            elif args[0][:6].lower() == "verify":
                chat_id = args[0].split("_")[1]
                verify_welcome(update, context, chat_id)

        else:
            first_name = update.effective_user.first_name
            buttons = InlineKeyboardMarkup(
                [[
                    InlineKeyboardButton(
                        text="📃 HitaloSama's Docs",
                        url="https://telegra.ph/HitaloKun-doc-07-15")
                ],
                 [
                     InlineKeyboardButton(text="⚙️ Connections",
                                          callback_data="main_connect")
                 ],
                 [
                     InlineKeyboardButton(text="🇺🇸 Language",
                                          callback_data="main_setlang"),
                     InlineKeyboardButton(
                         text="❓ Help",
                         url="https://t.me/LordHitsuki_BOT?start=help")
                 ]])
            update.effective_message.reply_text(tl(
                update.effective_message,
                PM_START_TEXT).format(escape_markdown(first_name),
                                      escape_markdown(context.bot.first_name),
                                      OWNER_ID),
                                                disable_web_page_preview=True,
                                                parse_mode=ParseMode.MARKDOWN,
                                                reply_markup=buttons)
    else:
        update.effective_message.reply_text(
            tl(update.effective_message, "Ada yang bisa saya bantu? 😊"))