from dacite import from_dict from pyrogram import Client, Filters, InlineQuery from ...functions import inlinekeyboard, db_tools from ...types import user as users def check_func(_, inline_query: InlineQuery): data = inline_query.query.split() if len(data) != 1: return False if data[0] == 'myacnh': return True @Client.on_inline_query(Filters.create(check_func)) def myacnh(client: Client, inline_query: InlineQuery): mongo = db_tools.use_mongo() mongo_query = {'chat.id': inline_query.from_user.id} mongo_result = mongo.nintendo.find_one(mongo_query) if not isinstance(mongo_result, dict): return user = from_dict(data_class=users, data=mongo_result) keyboard = inlinekeyboard.myacnh(user) inline_query.answer(keyboard, cache_time=0)
text="Bantuan", url=f"t.me/{setbot.get_me()['username']}?start=help") ]]) await message.reply( "Hubungi saya di PM untuk mendapatkan daftar perintah.", reply_markup=keyboard) return await help_parser(client, message.chat.id, HELP_STRINGS) def help_button_callback(_, query): if re.match(r"help_", query.data): return True help_button_create = Filters.create(help_button_callback) @setbot.on_callback_query(help_button_create) async def help_button(_client, query): mod_match = re.match(r"help_module\((.+?)\)", query.data) prev_match = re.match(r"help_prev\((.+?)\)", query.data) next_match = re.match(r"help_next\((.+?)\)", query.data) back_match = re.match(r"help_back", query.data) if True: if mod_match: module = mod_match.group(1) text = "This is help for the module **{}**:\n".format(HELP_COMMANDS[module].__MODULE__) \ + HELP_COMMANDS[module].__HELP__ await query.message.edit(text=text,
balance = round(cache.get_balance(message.chat.id)) usd = round(cache.get_price() * float(balance) * cache.get_price_like(), 2) app.send_message(message.chat.id, f"You've got {balance} LIKE.\nThat's about ${usd}", reply_markup=help_markup) @app.on_message((Filters.command(['topup']) | Filters.regex("Top up")) & Filters.private) def topup(client, message): tg_analytic.statistics(message.chat.id, "topup") data = db.create_user(message.chat.id) keyboard_markup = InlineKeyboardMarkup([[InlineKeyboardButton("QR Code", callback_data="qr_code"), InlineKeyboardButton( "Address", callback_data="address"), InlineKeyboardButton("BIP Wallet", url=data[-1])]]) app.send_message(message.chat.id, f"To top up your balance use one of the following options.\n\n<i>Hint: You've got to know a bit about crypto or ask your friend to help.</i>", parse_mode="html", reply_markup=keyboard_markup) @app.on_message(Filters.command(['spend']) & Filters.private) @app.on_message(Filters.create(lambda _, message: "Spend" in message.text) & Filters.private) def spend(client, message): tg_analytic.statistics(message.chat.id, "spend") #data = cache.get_tap_mn_push(message) data1 = cache.get_tap_minter_push(message) app.send_message(message.chat.id, f"Your LIKEs are like money, spend on anything:", parse_mode="Markdown", reply_markup=InlineKeyboardMarkup( [ # [InlineKeyboardButton("Tap mn", url=f"https://tap.mn/{data}")], [InlineKeyboardButton("Minterpush", url=data1)] ])) # Handler to Likes Messages with Emoji @app.on_message((Filters.create((lambda _, message: is_emoji(message.text) > 0)) | Filters.sticker | Filters.animation) & ~Filters.edited & ~Filters.private) def like_detect(client, message):
parse_mode="markdown", reply_to_message_id=message.message_id ) @Client.on_message(Filters.private & Filters.incoming & Filters.command(['help'])) def _help(client, message): client.send_message(chat_id = message.chat.id, text = tr.HELP_MSG[1], parse_mode="markdown", disable_notification = True, reply_markup = InlineKeyboardMarkup(map(1)), reply_to_message_id = message.message_id ) help_callback_filter = Filters.create(lambda _, query: query.data.startswith('help+')) @Client.on_callback_query(help_callback_filter) def help_answer(client, callback_query): chat_id = callback_query.from_user.id message_id = callback_query.message.message_id msg = int(callback_query.data.split('+')[1]) client.edit_message_text(chat_id=chat_id, message_id=message_id, text=tr.HELP_MSG[msg], reply_markup=InlineKeyboardMarkup(map(msg)) ) def map(pos): if(pos==1): button = [ [InlineKeyboardButton(text = '-->', callback_data = "help+2")]
from pyrogram import Client, Filters, Message, InlineKeyboardMarkup from .detect_language import keyboard @Client.on_message((Filters.command('start') & Filters.create(lambda _, m: len(m.command) > 1)) | Filters.command('changelang')) async def select_language_by_link(_client: Client, message: Message): await message.reply("Choose your language:", reply_markup=InlineKeyboardMarkup(keyboard[0]))
import asyncio from pyrogram import Filters from ..utils import sample_fn from ..screenshotbot import ScreenShotBot @ScreenShotBot.on_callback_query( Filters.create(lambda _, query: query.data.startswith('smpl'))) async def _(c, m): asyncio.create_task(sample_fn(c, m))
# You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. from pyrogram import (Client, Filters, Message) from bot import (AUTH_USERS, BAN_COMMAND, DERP_USER_S_TEXT, IS_BLACK_LIST_ED_MESSAGE_TEXT, IS_UN_BANED_MESSAGE_TEXT, REASON_DE_LIMIT_ER, UN_BAN_COMMAND) from bot.hf.gfi import (get_file_id) from bot.sql.users_sql import (get_user_id) from bot.sql.blacklist_sql import (add_user_to_bl, rem_user_from_bl) @Client.on_message( Filters.chat(AUTH_USERS) & Filters.create(lambda _, message: message.reply_to_message and message. reply_to_message.from_user.is_self)) async def on_pm_s(client: Client, message: Message): user_id, reply_message_id = get_user_id( message.reply_to_message.message_id) recvd_text = message.text.html + " " cmnd_message, ban_un_reason = recvd_text.split(" ", 1) cmnd_message = cmnd_message.strip() ban_un_reason = ban_un_reason.strip() if cmnd_message == BAN_COMMAND: add_user_to_bl(user_id, ban_un_reason) black_list_message = IS_BLACK_LIST_ED_MESSAGE_TEXT.format( reason=ban_un_reason) if not ban_un_reason:
from pyrogram import Client, Filters, Message @Client.on_message( Filters.text & Filters.private & Filters.create(lambda _, m: m.text == "/start howtosharecode")) async def how_to_share_code(_client: Client, message: Message): await message.reply(""" איך לשלוח קוד / שגיאה: **עדיפות ראשונה:** לשתף את הקוד באתר כמו nekobin.com, ולשתף כאן את הקישור. [מומלץ להחליף את סיומת txt לסיומת py]. **עדיפות שניה:** קיים כלי במחשב שמאפשר לבצע צילומי מסך על חלק ספציפי במסך, לוחצים ctrl + shift + s, בוחרים את האזור הרצוי שרוצים לשתף, לאחר מכן ניגשים לטלגרם ולוחצים ctrl + v. מומלץ גם לעבור על הקישור הזה: https://github.com/shlomif/how-to-share-code-online""")
def dynamic_data_filter(data): return Filters.create( lambda flt, query: flt.data == query.data, data=data # "data" kwarg is accessed with "flt.data" above )