示例#1
0
文件: wiki.py 项目: 4amparaboy/Keiko
import re
import json
from typing import Optional, List
import time
import urllib
from urllib.request import urlopen, urlretrieve
from urllib.parse import quote_plus, urlencode
import requests
from telegram import Message, Chat, Update, Bot, MessageEntity
from telegram import ParseMode
from telegram.ext import CommandHandler, run_async, Filters
from keiko import dispatcher
from keiko.modules.disable import DisableAbleCommandHandler
import wikipedia


def wiki(bot: Bot, update: Update, args):
    reply = " ".join(args)
    summary = '{} {}'
    update.message.reply_text(
        summary.format(wikipedia.summary(reply, sentences=3),
                       wikipedia.page(reply).url))


__help__ = """
 - /wiki text: Returns search from wikipedia for the input text
"""
__mod_name__ = "Wikipedia"
WIKI_HANDLER = DisableAbleCommandHandler("wiki", wiki, pass_args=True)
dispatcher.add_handler(WIKI_HANDLER)
示例#2
0
        else:
            wallpapers = json_rep.get("wallpapers")
            if not wallpapers:
                msg.reply_text("No results found! Refine your search.")
                return
            else:
                index = randint(0, len(wallpapers) - 1)  # Choose random index
                wallpaper = wallpapers[index]
                wallpaper = wallpaper.get("url_image")
                wallpaper = wallpaper.replace("\\", "")
                bot.send_photo(chat_id,
                               photo=wallpaper,
                               caption='Preview',
                               reply_to_message_id=msg_id,
                               timeout=60)
                bot.send_document(chat_id,
                                  document=wallpaper,
                                  filename='wallpaper',
                                  caption=caption,
                                  reply_to_message_id=msg_id,
                                  timeout=60)


__help__ = """
 - /wall <query>: get a a wallpaper from wall.alphacoders.com
"""

__mod_name__ = "Wallpaper"
WALL_HANDLER = DisableAbleCommandHandler("wall", wall, pass_args=True)
dispatcher.add_handler(WALL_HANDLER)
示例#3
0
文件: tts.py 项目: 4amparaboy/Keiko

@run_async
def tts(bot: Bot, update: Update, args):
    current_time = datetime.strftime(datetime.now(), "%d.%m.%Y %H:%M:%S")
    filename = datetime.now().strftime("%d%m%y-%H%M%S%f")
    reply = " ".join(args)
    update.message.chat.send_action(ChatAction.RECORD_AUDIO)
    lang="ml"
    tts = gTTS(reply, lang)
    tts.save("k.mp3")
    with open("k.mp3", "rb") as f:
        linelist = list(f)
        linecount = len(linelist)
    if linecount == 1:
        update.message.chat.send_action(ChatAction.RECORD_AUDIO)
        lang = "en"
        tts = gTTS(reply, lang)
        tts.save("k.mp3")
    with open("k.mp3", "rb") as speech:
        update.message.reply_voice(speech, quote=False)

__help__ = """
 - /tts <sentence>:  Text to Speech!
"""

__mod_name__ = "Text-to-Speech"

TTS_HANDLER = DisableAbleCommandHandler('tts', tts, pass_args=True)
dispatcher.add_handler(TTS_HANDLER)
示例#4
0
文件: covid.py 项目: 4amparaboy/Keiko
from keiko import dispatcher
from keiko.modules.disable import DisableAbleCommandHandler


@run_async
def covid(bot: Bot, update: Update):
    message = update.effective_message
    text = message.text.split(' ', 1)
    if len(text) == 1:
        r = requests.get(f"https://corona.lmao.ninja/v2/all").json()
        reply_text = f"**Global Totals** ­Ъда\nCases: {r['cases']:,}\nCases Today: {r['todayCases']:,}\nDeaths: {r['deaths']:,}\nDeaths Today: {r['todayDeaths']:,}\nRecovered: {r['recovered']:,}\nActive: {r['active']:,}\nCritical: {r['critical']:,}\nCases/Mil: {r['casesPerOneMillion']}\nDeaths/Mil: {r['deathsPerOneMillion']}"
    else:
        variabla = text[1]
        r = requests.get(
            f"https://corona.lmao.ninja/v2/countries/{variabla}").json()
        reply_text = f"**Cases for {r['country']} ­Ъда**\nCases: {r['cases']:,}\nCases Today: {r['todayCases']:,}\nDeaths: {r['deaths']:,}\nDeaths Today: {r['todayDeaths']:,}\nRecovered: {r['recovered']:,}\nActive: {r['active']:,}\nCritical: {r['critical']:,}\nCases/Mil: {r['casesPerOneMillion']}\nDeaths/Mil: {r['deathsPerOneMillion']}"
    message.reply_text(reply_text, parse_mode=ParseMode.MARKDOWN)


__help__ = """
 - /covid To get Global data
 - /covid <country> To get data of a country
"""

COVID_HANDLER = DisableAbleCommandHandler(["covid", "corona"], covid)

dispatcher.add_handler(COVID_HANDLER)

__mod_name__ = "Corona Info"
示例#5
0
        f"Finding timezone info for <b>{query}</b>", parse_mode=ParseMode.HTML)

    query_timezone = query.lower()
    if len(query_timezone) == 2:
        result = generate_time(query_timezone, ["countryCode"])
    else:
        result = generate_time(query_timezone, ["zoneName", "countryName"])

    if not result:
        send_message.edit_text(
            f"Timezone info not available for <b>{query}</b>",
            parse_mode=ParseMode.HTML)
        return

    send_message.edit_text(result, parse_mode=ParseMode.HTML)


__help__ = """
 - /time <query> : Gives information about a timezone.

Available queries : Country Code/Country Name/Timezone Name
"""

TIME_HANDLER = DisableAbleCommandHandler("time", gettime)

dispatcher.add_handler(TIME_HANDLER)

__mod_name__ = "Time"
__command_list__ = ["time"]
__handlers__ = [TIME_HANDLER]
示例#6
0
                                                    url=f"t.me/{bot.username}")
                           ]]))
        return

    if success:
        msg.reply_text(
            f"Sticker pack successfully created. Get it [here](t.me/addstickers/{packname})",
            parse_mode=ParseMode.MARKDOWN)
    else:
        msg.reply_text(
            "Failed to create sticker pack. Possibly due to blek mejik.")


__help__ = """
- /stickerid: reply to a sticker to me to tell you its file ID.
- /getsticker: reply to a sticker to me to upload its raw PNG file.
- /kang: reply to a sticker to add it to your pack.
"""

__mod_name__ = "Stickers"
STICKERID_HANDLER = DisableAbleCommandHandler("stickerid", stickerid)
GETSTICKER_HANDLER = DisableAbleCommandHandler("getsticker", getsticker)
KANG_HANDLER = DisableAbleCommandHandler("kang",
                                         kang,
                                         pass_args=True,
                                         admin_ok=True)

dispatcher.add_handler(STICKERID_HANDLER)
dispatcher.add_handler(GETSTICKER_HANDLER)
dispatcher.add_handler(KANG_HANDLER)
示例#7
0
    # RAM Usage
    svmem = psutil.virtual_memory()
    memm = "--- Memory Usage ---\n"
    memm += f"Total: `{get_size(svmem.total)}`\n"
    memm += f"Available: `{get_size(svmem.available)}`\n"
    memm += f"Used: `{get_size(svmem.used)}`\n"
    memm += f"Percentage: `{svmem.percent}%`\n"
    reply = str(stat) + str(softw) + str(cpuu) + str(memm) + "\n"
    bot.send_message(chat.id, reply, parse_mode=ParseMode.MARKDOWN)


__help__ = """
- /system : To know System status
- /speed or - /speedtest: To find Speed
"""

SPEED_TEST_HANDLER = DisableAbleCommandHandler(
    ["speedtest", "speed"], speedtestxyz, filters=CustomFilters.sudo_filter)
SPEED_TEST_CALLBACKHANDLER = CallbackQueryHandler(speedtestxyz_callback,
                                                  pattern='speedtest_.*')
STATUS_HANDLER = CommandHandler("system",
                                status,
                                filters=CustomFilters.sudo_filter)

dispatcher.add_handler(SPEED_TEST_HANDLER)
dispatcher.add_handler(SPEED_TEST_CALLBACKHANDLER)
dispatcher.add_handler(STATUS_HANDLER)

__mod_name__ = "SYSTEM INFO"
__command_list__ = ["speedtest"]
__handlers__ = [SPEED_TEST_HANDLER, SPEED_TEST_CALLBACKHANDLER]
示例#8
0
文件: gps.py 项目: 4amparaboy/Keiko
def gps(bot: Bot, update: Update, args: List[str]):
    message = update.effective_message
    if len(args) == 0:
        update.effective_message.reply_text(
            "That was a funny joke, but no really, put in a location")
    try:
        geolocator = Nominatim(user_agent="SkittBot")
        location = " ".join(args)
        geoloc = geolocator.geocode(location)
        chat_id = update.effective_chat.id
        lon = geoloc.longitude
        lat = geoloc.latitude
        the_loc = Location(lon, lat)
        gm = "https://www.google.com/maps/search/{},{}".format(lat, lon)
        bot.send_location(chat_id, location=the_loc)
        update.message.reply_text("Open with: [Google Maps]({})".format(gm),
                                  parse_mode=ParseMode.MARKDOWN,
                                  disable_web_page_preview=True)
    except AttributeError:
        update.message.reply_text("I can't find that")


__help__ = """
 - /gps <location>: get gps location 
"""

__mod_name__ = "GPS"

GPS_HANDLER = DisableAbleCommandHandler("gps", gps, pass_args=True)

dispatcher.add_handler(GPS_HANDLER)
示例#9
0
文件: warns.py 项目: 4amparaboy/Keiko
 - /strongwarn <on/yes/off/no>: If set to on, exceeding the warn limit will result in a ban. Else, will just punch.
"""

__mod_name__ = "Warnings"

WARN_HANDLER = CommandHandler("warn",
                              warn_user,
                              pass_args=True,
                              filters=Filters.group)
RESET_WARN_HANDLER = CommandHandler(["resetwarn", "resetwarns"],
                                    reset_warns,
                                    pass_args=True,
                                    filters=Filters.group)
CALLBACK_QUERY_HANDLER = CallbackQueryHandler(button, pattern=r"rm_warn")
MYWARNS_HANDLER = DisableAbleCommandHandler("warns",
                                            warns,
                                            pass_args=True,
                                            filters=Filters.group)
ADD_WARN_HANDLER = CommandHandler("addwarn",
                                  add_warn_filter,
                                  filters=Filters.group)
RM_WARN_HANDLER = CommandHandler(["nowarn", "stopwarn"],
                                 remove_warn_filter,
                                 filters=Filters.group)
LIST_WARN_HANDLER = DisableAbleCommandHandler(["warnlist", "warnfilters"],
                                              list_warn_filters,
                                              filters=Filters.group,
                                              admin_ok=True)
WARN_FILTER_HANDLER = MessageHandler(CustomFilters.has_text & Filters.group,
                                     reply_filter)
WARN_LIMIT_HANDLER = CommandHandler("warnlimit",
                                    set_warn_limit,
示例#10
0
        reply_text = "User not found. Make sure you entered valid username!"
    message.reply_text(reply_text, parse_mode=ParseMode.MARKDOWN)



@run_async
def repo(bot: Bot, update: Update, args: [str]):
    message = update.effective_message
    text = message.text[len('/repo '):]
    usr = get(f'https://api.github.com/users/{text}/repos?per_page=40').json()
    reply_text = "*Repo*\n"
    for i in range(len(usr)):
        reply_text += f"[{usr[i]['name']}]({usr[i]['html_url']})\n"
    message.reply_text(reply_text, parse_mode=ParseMode.MARKDOWN, disable_web_page_preview=True)

 
__help__ = """
 - /git:{GitHub username} Returns info about a GitHub user or organization.
 - /repo: Return the GitHub user or organization repository list (Limited at 40)
"""

__mod_name__ = "Github"

github_handle = DisableAbleCommandHandler("git", github)
REPO_HANDLER = DisableAbleCommandHandler("repo", repo, pass_args=True, admin_ok=True)




dispatcher.add_handler(github_handle)
dispatcher.add_handler(REPO_HANDLER)
示例#11
0
                    "Translated from `{}` to `{}`:\n`{}`".format(
                        source_lang, dest_lang, tekstr.text),
                    parse_mode=ParseMode.MARKDOWN)

    except IndexError:
        update.effective_message.reply_text(
            "Reply to messages or write messages from other languages ​​for translating into the intended language\n\n"
            "Example: `/tr en ml` to translate from English to Malayalam\n"
            "Or use: `/tr ml` for automatic detection and translating it into Malayalam.\n"
            "See [List of Language Codes](t.me/OnePunchSupport/12823) for a list of language codes.",
            parse_mode="markdown",
            disable_web_page_preview=True)
    except ValueError:
        update.effective_message.reply_text(
            "The intended language is not found!")
    else:
        return


__help__ = """
- /tr (language code) as reply to a long message.
"""

TRANSLATE_HANDLER = DisableAbleCommandHandler("tr", totranslate)

dispatcher.add_handler(TRANSLATE_HANDLER)

__mod_name__ = "Translator"
__command_list__ = ["tr"]
__handlers__ = [TRANSLATE_HANDLER]
示例#12
0
@run_async
def me_too(bot: Bot, update: Update):
    message = update.effective_message
    if random.randint(0, 100) > 60:
        reply = random.choice(["Me too thanks", "Haha yes, me too", "Same lol", "Me irl"])
        message.reply_text(reply)


__help__ = """
- Reply to a text with /🅱️ or /😂 or /👏
- You can also use the text version of these : /bmoji or /copypasta or /clapmoji
"""

__mod_name__ = "Emojis"

COPYPASTA_HANDLER = DisableAbleCommandHandler("copypasta", copypasta)
COPYPASTA_ALIAS_HANDLER = DisableAbleCommandHandler("😂", copypasta)
CLAPMOJI_HANDLER = DisableAbleCommandHandler("clapmoji", clapmoji)
CLAPMOJI_ALIAS_HANDLER = DisableAbleCommandHandler("👏", clapmoji)
ANGRYMOJI_HANDLER = DisableAbleCommandHandler("angrymoji", angrymoji)
ANGRYMOJI_ALIAS_HANDLER = DisableAbleCommandHandler("😡", angrymoji)
CRYMOJI_HANDLER = DisableAbleCommandHandler("crymoji", crymoji)
CRYMOJI_ALIAS_HANDLER = DisableAbleCommandHandler("😭", crymoji)
BMOJI_HANDLER = DisableAbleCommandHandler("🅱️", bmoji)
BMOJI_ALIAS_HANDLER = DisableAbleCommandHandler("bmoji", bmoji)

dispatcher.add_handler(COPYPASTA_HANDLER)
dispatcher.add_handler(COPYPASTA_ALIAS_HANDLER)
dispatcher.add_handler(CLAPMOJI_HANDLER)
dispatcher.add_handler(CLAPMOJI_ALIAS_HANDLER)
dispatcher.add_handler(ANGRYMOJI_HANDLER)
示例#13
0
from keiko import dispatcher
from keiko.modules.disable import DisableAbleCommandHandler


@run_async
def ddlc(bot: Bot, update: Update):
    msg = update.effective_message
    args = update.effective_message.text.split(" ", 5)
    character = args[1]
    background = args[2]
    body = args[3]
    face = args[4]
    text = args[5]
    rq = requests.get(
        f"https://nekobot.xyz/api/imagegen?type=ddlc&character={character}&background={background}&body={body}&face={face}&text={text}"
    ).json()
    message = rq.get("message")
    # do shit with url if you want to
    if not message:
        msg.reply_text("No URL was received from the API!")
        return
    msg.reply_photo(message)


__help__ = """[Documentation](https://telegra.ph/DDLC-Documentation-05-18)"""
__mod_name__ = "DDLC"

DDLC_HANDLER = DisableAbleCommandHandler("ddlc", ddlc)

dispatcher.add_handler(DDLC_HANDLER)
示例#14
0
文件: purge.py 项目: 4amparaboy/Keiko
                    f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n"
                    f"Message deleted.")
    else:
        update.effective_message.reply_text("Whadya want to delete?")

    return ""


__help__ = """
*Admin only:*
 - /del: deletes the message you replied to
 - /purge: deletes all messages between this and the replied to message.
 - /purge <integer X>: deletes the replied message, and X messages following it if replied to a message.
 - /purge <integer X>: deletes the number of messages starting from bottom. (Counts manaully deleted messages too)
"""

DELETE_HANDLER = DisableAbleCommandHandler("del",
                                           del_message,
                                           filters=Filters.group)
PURGE_HANDLER = DisableAbleCommandHandler("purge",
                                          purge,
                                          filters=Filters.group,
                                          pass_args=True)

dispatcher.add_handler(DELETE_HANDLER)
dispatcher.add_handler(PURGE_HANDLER)

__mod_name__ = "Purges"
__command_list__ = ["del", "purge"]
__handlers__ = [DELETE_HANDLER, PURGE_HANDLER]
示例#15
0
    "ヽ(>∀<☆)ノ", "\( ̄▽ ̄)/", "(o˘◡˘o)", "(╯✧▽✧)╯", "( ‾́ ◡ ‾́ )", "(๑˘︶˘๑)",
    "(´・ᴗ・ ` )", "( ͡° ʖ̯ ͡°)", "( ఠ ͟ʖ ఠ)", "( ಥ ʖ̯ ಥ)", "(≖ ͜ʖ≖)", "ヘ( ̄ω ̄ヘ)",
    "(ノ≧∀≦)ノ", "└( ̄- ̄└))", "┌(^^)┘", "(^_^♪)", "(〜 ̄△ ̄)〜", "(「• ω •)「",
    "( ˘ ɜ˘) ♬♪♫", "( o˘◡˘o) ┌iii┐", "♨o(>_<)o♨", "( ・・)つ―{}@{}@{}-",
    "(*´з`)口゚。゚口(・∀・ )", "( *^^)o∀*∀o(^^* )", "-●●●-c(・・ )", "(ノ≧∀≦)ノ ‥…━━━★",
    "╰( ͡° ͜ʖ ͡° )つ──☆*:・゚", "(∩ᄑ_ᄑ)⊃━☆゚*・。*・:≡( ε:)"
]


@run_async
def react(bot: Bot, update: Update):
    message = update.effective_message
    react = random.choice(reactions)
    if message.reply_to_message:
        message.reply_to_message.reply_text(react)
    else:
        message.reply_text(react)


__help__ = """
 - /react: Reacts with a random reaction
"""

REACT_HANDLER = DisableAbleCommandHandler("react", react)

dispatcher.add_handler(REACT_HANDLER)

__mod_name__ = "React"
__command_list__ = ["react"]
__handlers__ = [REACT_HANDLER]
示例#16
0
    elif bio:
        return f"\n<b>What others say:</b>\n{bio}\n"
    elif me:
        return f"\n<b>About user:</b>\n{me}\n"
    else:
        return "\n"


__help__ = """
 - /setbio <text>: while replying, will save another user's bio
 - /bio: will get your or another user's bio. This cannot be set by yourself.
 - /setme <text>: will set your info
 - /me: will get your or another user's info
"""

SET_BIO_HANDLER = DisableAbleCommandHandler("setbio", set_about_bio)
GET_BIO_HANDLER = DisableAbleCommandHandler("bio", about_bio, pass_args=True)

SET_ABOUT_HANDLER = DisableAbleCommandHandler("setme", set_about_me)
GET_ABOUT_HANDLER = DisableAbleCommandHandler("me", about_me, pass_args=True)

dispatcher.add_handler(SET_BIO_HANDLER)
dispatcher.add_handler(GET_BIO_HANDLER)
dispatcher.add_handler(SET_ABOUT_HANDLER)
dispatcher.add_handler(GET_ABOUT_HANDLER)

__mod_name__ = "Bios and Abouts"
__command_list__ = ["setbio", "bio", "setme", "me"]
__handlers__ = [
    SET_BIO_HANDLER, GET_BIO_HANDLER, SET_ABOUT_HANDLER, GET_ABOUT_HANDLER
]
示例#17
0
    upt_header = "".join(b)
    f = int(uptime())
    pcuptime = seconds_to_str(f)
    up = "{}\n\nUptime: {}\n".format(upt_header, pcuptime)
    c = "=" * 15, " CPU ", "=" * 15
    cpu_header = "".join(c)
    cpumodel = cpuinfo.get_cpu_info()['brand']
    cpufreq = psutil.cpu_freq()
    cpu_info = "{}\n\n{}\nPhysical cores: {}\nTotal cores: {}\nMax Frequency: {:.2f} Mhz\nCurrent Frequency: {:.2f} Mhz\nCPU Usage: {}%\n".format(
        cpu_header, cpumodel, psutil.cpu_count(logical=False),
        psutil.cpu_count(logical=True), cpufreq.max, cpufreq.current,
        psutil.cpu_percent(percpu=False, interval=1))
    d = "=" * 15, " RAM ", "=" * 15
    ram_header = "".join(d)
    svmem = psutil.virtual_memory()
    ram_info = "{}\n\nTotal: {}\nAvailable: {} ({:.2f}%)\nUsed: {} ({:.2f}%)\n".format(
        ram_header, get_size(svmem.total), get_size(svmem.available),
        100 - svmem.percent, get_size(svmem.used), svmem.percent)
    server_status = "```\n{}\n{}\n{}\n{}\n```".format(sys_info, up, cpu_info,
                                                      ram_info)
    update.message.reply_text(server_status, parse_mode="Markdown")


__help__ = """
 **Dev Only!**
 - /sysinfo - Gives information about bot hosted server.
"""
__mod_name__ = "System Info"
SYSINFO_HANDLER = DisableAbleCommandHandler("sysinfo", sysinfo)
dispatcher.add_handler(SYSINFO_HANDLER)
示例#18
0
__help__ = """
Blacklists are used to stop certain triggers from being said in a group. Any time the trigger is mentioned, \
the message will immediately be deleted. A good combo is sometimes to pair this up with warn filters!
*NOTE:* blacklists do not affect group admins.
 - /blacklist: View the current blacklisted words.
*Admin only:*
 - /addblacklist <triggers>: Add a trigger to the blacklist. Each line is considered one trigger, so using different \
lines will allow you to add multiple triggers.
 - /unblacklist <triggers>: Remove triggers from the blacklist. Same newline logic applies here, so you can remove \
multiple triggers at once.
 - /rmblacklist <triggers>: Same as above.
"""

BLACKLIST_HANDLER = DisableAbleCommandHandler("blacklist",
                                              blacklist,
                                              pass_args=True,
                                              admin_ok=True)
ADD_BLACKLIST_HANDLER = CommandHandler("addblacklist", add_blacklist)
UNBLACKLIST_HANDLER = CommandHandler(["unblacklist", "rmblacklist"],
                                     unblacklist)
BLACKLIST_DEL_HANDLER = MessageHandler(
    (Filters.text | Filters.command | Filters.sticker | Filters.photo)
    & Filters.group,
    del_blacklist,
    edited_updates=True)
dispatcher.add_handler(BLACKLIST_HANDLER)
dispatcher.add_handler(ADD_BLACKLIST_HANDLER)
dispatcher.add_handler(UNBLACKLIST_HANDLER)
dispatcher.add_handler(BLACKLIST_DEL_HANDLER, group=BLACKLIST_GROUP)

__mod_name__ = "Blacklist Word"
示例#19
0
文件: memes.py 项目: 4amparaboy/Keiko
Some memes command, find it all out yourself!
- /owo: OWO de text
- /stretch: STRETCH de text
- /vapor: owo vapor dis
- /mock: mocks a spongebob image with text
- /shout: Write anything that u want it to should
- /zalgofy: reply to a message to g̫̞l̼̦i̎͡tͫ͢c̘ͭh̛̗ it out!
- /kan: reply a text to kannafy.
- /changemymind: reply a text to stickerize.
- /trumptweet: reply a text for trump tweet.
- /eightball: shakes 8ball.
"""

__mod_name__ = "Memes and etc."

OWO_HANDLER = DisableAbleCommandHandler("owo", owo, admin_ok=True)
STRETCH_HANDLER = DisableAbleCommandHandler("stretch", stretch)
VAPOR_HANDLER = DisableAbleCommandHandler("vapor",
                                          vapor,
                                          pass_args=True,
                                          admin_ok=True)
ZALGO_HANDLER = DisableAbleCommandHandler("zalgofy", zalgotext)
DEEPFRY_HANDLER = DisableAbleCommandHandler("deepfry",
                                            deepfryer,
                                            admin_ok=True)
SHOUT_HANDLER = DisableAbleCommandHandler("shout", shout, pass_args=True)
KAN_HANDLER = DisableAbleCommandHandler("kan", kan)
CHANGEMYMIND_HANDLER = DisableAbleCommandHandler("changemymind", changemymind)
TRUMPTWEET_HANDLER = DisableAbleCommandHandler("trumptweet", trumptweet)
EIGHTBALL_HANDLER = DisableAbleCommandHandler("eightball", eightball)
示例#20
0
@run_async
def clock(bot: Bot, update: Update):
    message = update.effective_message.reply_text('/moon')

    animation_chars = [
        "🕙🕘🕖🕕🕔🕓🕒🕑🕐🕛", "🕘🕗🕕🕔🕓🕒🕑🕐🕛🕙", "🕗🕕🕔🕓🕒🕑🕐🕛🕙🕘", "🕕🕔🕓🕒🕑🕐🕛🕙🕘🕗", "🕔🕓🕒🕑🕐🕛🕙🕘🕗🕕",
        "🕓🕒🕑🕐🕛🕙🕘🕗🕕🕔", "🕒🕑🕐🕛🕙🕘🕗🕕🕔🕓", "🕑🕐🕛🕙🕘🕗🕕🕔🕓🕒", "*tick-tock*"
    ]
    for i in animation_chars:
        message.edit_text(i)
        sleep(0.5)


__help__ = """
 - /police : *Sirens* Polize iz here
 - /moon : Cycles all the phases of the moon emojis.
 - /clock : Cycles all the phases of the clock emojis.
"""

POLICE_HANDLER = DisableAbleCommandHandler(["police"], police)
MOON_HANDLER = DisableAbleCommandHandler(["moon"], moon)
CLOCK_HANDLER = DisableAbleCommandHandler(["clock"], clock)

dispatcher.add_handler(POLICE_HANDLER)
dispatcher.add_handler(MOON_HANDLER)
dispatcher.add_handler(CLOCK_HANDLER)

__mod_name__ = "Parser"
__command_list__ = ["police", "moon", "clock"]
__handlers__ = [POLICE_HANDLER, MOON_HANDLER, CLOCK_HANDLER]
示例#21
0
文件: misc.py 项目: 4amparaboy/Keiko
@run_async
@sudo_plus
def stats(bot: Bot, update: Update):
    stats = "Current stats:\n" + "\n".join([mod.__stats__() for mod in STATS])
    result = re.sub(r'(\d+)', r'<code>\1</code>', stats)
    update.effective_message.reply_text(result, parse_mode=ParseMode.HTML)


__help__ = """
 - /id: get the current group id. If used by replying to a message, gets that user's id.
 - /gifid: reply to a gif to me to tell you its file ID.
 - /info: get information about a user.
 - /markdownhelp: quick summary of how markdown works in telegram - can only be called in private chats.
"""

ID_HANDLER = DisableAbleCommandHandler("id", get_id, pass_args=True)
GIFID_HANDLER = DisableAbleCommandHandler("gifid", gifid)
INFO_HANDLER = DisableAbleCommandHandler("info", info, pass_args=True)
ECHO_HANDLER = DisableAbleCommandHandler("echo", echo, filters=Filters.group)
MD_HELP_HANDLER = CommandHandler("markdownhelp",
                                 markdown_help,
                                 filters=Filters.private)
STATS_HANDLER = CommandHandler("stats", stats)

dispatcher.add_handler(ID_HANDLER)
dispatcher.add_handler(GIFID_HANDLER)
dispatcher.add_handler(INFO_HANDLER)
dispatcher.add_handler(ECHO_HANDLER)
dispatcher.add_handler(MD_HELP_HANDLER)
dispatcher.add_handler(STATS_HANDLER)
示例#22
0
"""

__mod_name__ = "Special"

LEAVECHAT_HANDLER = CommandHandler("leavechat",
                                   leavechat,
                                   pass_args=True,
                                   filters=Filters.user(OWNER_ID))
SLIST_HANDLER = CommandHandler("slist",
                               slist,
                               filters=CustomFilters.sudo_filter
                               | CustomFilters.support_filter)
SNIPE_HANDLER = CommandHandler("snipe",
                               snipe,
                               pass_args=True,
                               filters=CustomFilters.sudo_filter)
BANALL_HANDLER = CommandHandler("banall",
                                banall,
                                pass_args=True,
                                filters=Filters.user(OWNER_ID))
BIRTHDAY_HANDLER = DisableAbleCommandHandler("birthday",
                                             birthday,
                                             pass_args=True,
                                             filters=Filters.group)

dispatcher.add_handler(SNIPE_HANDLER)
dispatcher.add_handler(BANALL_HANDLER)
dispatcher.add_handler(BIRTHDAY_HANDLER)
dispatcher.add_handler(LEAVECHAT_HANDLER)
dispatcher.add_handler(SLIST_HANDLER)
示例#23
0
__help__ = """
 - /locktypes: a list of possible locktypes

*Admin only:*
 - /lock <type>: lock items of a certain type (not available in private)
 - /unlock <type>: unlock items of a certain type (not available in private)
 - /locks: the current list of locks in this chat.

Locks can be used to restrict a group's users.
eg:
Locking urls will auto-delete all messages with urls which haven't been whitelisted, locking stickers will delete all \
stickers, etc.
Locking bots will stop non-admins from adding bots to the chat.
"""

LOCKTYPES_HANDLER = DisableAbleCommandHandler("locktypes", locktypes)
LOCK_HANDLER = CommandHandler("lock", lock, pass_args=True)
UNLOCK_HANDLER = CommandHandler("unlock", unlock, pass_args=True)
LOCKED_HANDLER = CommandHandler("locks", list_locks)
LOCKABLE_HANDLER = MessageHandler(Filters.all & Filters.group, del_lockables)
RESTRICTION_HANDLER = MessageHandler(Filters.all & Filters.group, rest_handler)

dispatcher.add_handler(LOCK_HANDLER)
dispatcher.add_handler(UNLOCK_HANDLER)
dispatcher.add_handler(LOCKTYPES_HANDLER)
dispatcher.add_handler(LOCKED_HANDLER)
dispatcher.add_handler(LOCKABLE_HANDLER, PERM_GROUP)
dispatcher.add_handler(RESTRICTION_HANDLER, REST_GROUP)

__mod_name__ = "Locks"
__handlers__ = [
示例#24
0
文件: nsfw.py 项目: 4amparaboy/Keiko
 - /waifu: Sends Random Waifu Stickers.
 - /kiss: Sends Random Kissing GIFs.
 - /femdom: Sends Random Femdom source Images.
 - /cuddle: Sends Random Cuddle GIFs.
 - /erok: Sends Random Ero-Kitsune source Images.
 - /foxgirl: Sends Random FoxGirl source Images.
 - /titsgif: Sends Random T**s GIFs.
 - /ero: Sends Random Ero source Images.
 - /smug: Sends Random Smug GIFs.
 - /baka: Sends Random Baka Shout GIFs.
 - /dva: Sends Random D.VA source Images.
"""

__mod_name__ = "Nekos API"

LEWDKEMO_HANDLER = DisableAbleCommandHandler("lewdkemo", lewdkemo)
NEKO_HANDLER = DisableAbleCommandHandler("neko", neko)
FEET_HANDLER = DisableAbleCommandHandler("feet", feet)
YURI_HANDLER = DisableAbleCommandHandler("yuri", yuri)
TRAP_HANDLER = DisableAbleCommandHandler("trap", trap)
FUTANARI_HANDLER = DisableAbleCommandHandler("futanari", futanari)
HOLOLEWD_HANDLER = DisableAbleCommandHandler("hololewd", hololewd)
SOLOGIF_HANDLER = DisableAbleCommandHandler("sologif", sologif)
CUMGIF_HANDLER = DisableAbleCommandHandler("cumgif", cumgif)
EROKEMO_HANDLER = DisableAbleCommandHandler("erokemo", erokemo)
LESBIAN_HANDLER = DisableAbleCommandHandler("lesbian", lesbian)
WALLPAPER_HANDLER = DisableAbleCommandHandler("wallpaper", wallpaper)
LEWDK_HANDLER = DisableAbleCommandHandler("lewdk", lewdk)
NGIF_HANDLER = DisableAbleCommandHandler("ngif", ngif)
TICKLE_HANDLER = DisableAbleCommandHandler("tickle", tickle)
LEWD_HANDLER = DisableAbleCommandHandler("lewd", lewd)
示例#25
0
    site_search(bot, update, "kayo")


__help__ = """
Get information about anime, manga or characters from [MyAnimeList](https://myanimelist.net).
*Available commands:*
 - /anime <anime>: returns information about the anime.
 - /character <character>: returns information about the character.
 - /manga <manga>: returns information about the manga.
 - /user <user>: returns information about a MyAnimeList user.
 - /upcoming: returns a list of new anime in the upcoming seasons.
 - /kaizoku <anime>: search an anime on animekaizoku.com
 - /kayo <anime>: search an anime on animekayo.com
 """

ANIME_HANDLER = DisableAbleCommandHandler("anime", anime)
CHARACTER_HANDLER = DisableAbleCommandHandler("character", character)
MANGA_HANDLER = DisableAbleCommandHandler("manga", manga)
USER_HANDLER = DisableAbleCommandHandler("user", user)
UPCOMING_HANDLER = DisableAbleCommandHandler("upcoming", upcoming)
KAIZOKU_SEARCH_HANDLER = DisableAbleCommandHandler("kaizoku", kaizoku)
KAYO_SEARCH_HANDLER = DisableAbleCommandHandler("kayo", kayo)
BUTTON_HANDLER = CallbackQueryHandler(button, pattern='anime_.*')

dispatcher.add_handler(BUTTON_HANDLER)
dispatcher.add_handler(ANIME_HANDLER)
dispatcher.add_handler(CHARACTER_HANDLER)
dispatcher.add_handler(MANGA_HANDLER)
dispatcher.add_handler(USER_HANDLER)
dispatcher.add_handler(KAIZOKU_SEARCH_HANDLER)
dispatcher.add_handler(KAYO_SEARCH_HANDLER)
示例#26
0
                reply = song.format()
            else:
                reply = "Couldn't find any lyrics for that song!"
        else:
            reply = "Song not found!"
        if len(reply) > 4090:
            with open("lyrics.txt", 'w') as f:
                f.write(f"{reply}\n\n\nOwO UwU OmO")
            with open("lyrics.txt", 'rb') as f:
                msg.reply_document(
                    document=f,
                    caption=
                    "Message length exceeded max limit! Sending as a text file."
                )
        else:
            msg.reply_text(reply)


__help__ = """
Want to get the lyrics of your favorite songs straight from the app? This module is perfect for that!
*Available commands:*
 - /lyrics <song>: returns the lyrics of that song.
 You can either enter just the song name or both the artist and song name.
"""

__mod_name__ = "Lyrics"

LYRICS_HANDLER = DisableAbleCommandHandler("lyrics", lyrics, pass_args=True)

dispatcher.add_handler(LYRICS_HANDLER)
示例#27
0
文件: notes.py 项目: 4amparaboy/Keiko
 - /get <notename>: get the note with this notename
 - #<notename>: same as /get
 - /notes or /saved: list all saved notes in this chat

If you would like to retrieve the contents of a note without any formatting, use `/get <notename> noformat`. This can \
be useful when updating a current note.

*Admin only:*
 - /save <notename> <notedata>: saves notedata as a note with name notename
A button can be added to a note by using standard markdown link syntax - the link should just be prepended with a \
`buttonurl:` section, as such: `[somelink](buttonurl:example.com)`. Check /markdownhelp for more info.
 - /save <notename>: save the replied message as a note with name notename
 - /clear <notename>: clear note with this name
"""

__mod_name__ = "Notes"

GET_HANDLER = CommandHandler("get", cmd_get, pass_args=True)
HASH_GET_HANDLER = RegexHandler(r"^#[^\s]+", hash_get)

SAVE_HANDLER = CommandHandler("save", save)
DELETE_HANDLER = CommandHandler("clear", clear, pass_args=True)

LIST_HANDLER = DisableAbleCommandHandler(["notes", "saved"], list_notes, admin_ok=True)

dispatcher.add_handler(GET_HANDLER)
dispatcher.add_handler(SAVE_HANDLER)
dispatcher.add_handler(LIST_HANDLER)
dispatcher.add_handler(DELETE_HANDLER)
dispatcher.add_handler(HASH_GET_HANDLER)
示例#28
0
文件: admin.py 项目: 4amparaboy/Keiko
    return "You are *admin*: `{}`".format(dispatcher.bot.get_chat_member(chat_id, user_id).status in ("administrator", "creator"))


__help__ = """
 - /adminlist: list of admins in the chat

*Admin only:*
 - /pin: silently pins the message replied to - add 'loud' or 'notify' to give notifs to users.
 - /unpin: unpins the currently pinned message
 - /invitelink: gets invitelink
 - /promote: promotes the user replied to
 - /demote: demotes the user replied to
 - /settitle: sets a custom title for an admin that the bot promoted
"""

ADMINLIST_HANDLER = DisableAbleCommandHandler(["adminlist", "admins"], adminlist)

PIN_HANDLER = CommandHandler("pin", pin, pass_args=True, filters=Filters.group)
UNPIN_HANDLER = CommandHandler("unpin", unpin, filters=Filters.group)

INVITE_HANDLER = DisableAbleCommandHandler("invitelink", invite, filters=Filters.group)

PROMOTE_HANDLER = CommandHandler("promote", promote, pass_args=True)
DEMOTE_HANDLER = CommandHandler("demote", demote, pass_args=True)

SET_TITLE_HANDLER = CommandHandler("settitle", set_title, pass_args=True)

dispatcher.add_handler(ADMINLIST_HANDLER)
dispatcher.add_handler(PIN_HANDLER)
dispatcher.add_handler(UNPIN_HANDLER)
dispatcher.add_handler(INVITE_HANDLER)
示例#29
0
文件: math.py 项目: 4amparaboy/Keiko
 - /sin: Sine `/sin 0`
 - /tan: Tangent `/tan 0`
 - /arccos: Inverse Cosine `/arccos 1`
 - /arcsin: Inverse Sine `/arcsin 0`
 - /arctan: Inverse Tangent `/arctan 0`
 - /abs: Absolute Value `/abs -1`
 - /log: Logarithm `/log 2l8`

__Keep in mind__: To find the tangent line of a function at a certain x value, send the request as c|f(x) where c is the given x value and f(x) is the function expression, the separator is a vertical bar '|'. See the table above for an example request.
To find the area under a function, send the request as c:d|f(x) where c is the starting x value, d is the ending x value, and f(x) is the function under which you want the curve between the two x values.
To compute fractions, enter expressions as numerator(over)denominator. For example, to process 2/4 you must send in your expression as 2(over)4. The result expression will be in standard math notation (1/2, 3/4).
"""

__mod_name__ = "Math"

SIMPLIFY_HANDLER = DisableAbleCommandHandler("math", simplify, pass_args=True)
FACTOR_HANDLER = DisableAbleCommandHandler("factor", factor, pass_args=True)
DERIVE_HANDLER = DisableAbleCommandHandler("derive", derive, pass_args=True)
INTEGRATE_HANDLER = DisableAbleCommandHandler("integrate",
                                              integrate,
                                              pass_args=True)
ZEROES_HANDLER = DisableAbleCommandHandler("zeroes", zeroes, pass_args=True)
TANGENT_HANDLER = DisableAbleCommandHandler("tangent", tangent, pass_args=True)
AREA_HANDLER = DisableAbleCommandHandler("area", area, pass_args=True)
COS_HANDLER = DisableAbleCommandHandler("cos", cos, pass_args=True)
SIN_HANDLER = DisableAbleCommandHandler("sin", sin, pass_args=True)
TAN_HANDLER = DisableAbleCommandHandler("tan", tan, pass_args=True)
ARCCOS_HANDLER = DisableAbleCommandHandler("arccos", arccos, pass_args=True)
ARCSIN_HANDLER = DisableAbleCommandHandler("arcsin", arcsin, pass_args=True)
ARCTAN_HANDLER = DisableAbleCommandHandler("arctan", arctan, pass_args=True)
ABS_HANDLER = DisableAbleCommandHandler("abs", abs, pass_args=True)
示例#30
0
    if int(lim) > 10:
        lim = 10

    imglinks = []
    counter = 0

    pattern = r'^,\[\"(.*[.png|.jpg|.jpeg])\",[0-9]+,[0-9]+\]$'
    oboi = re.findall(pattern, decoded, re.I | re.M)

    for imglink in oboi:
        counter += 1
        imglinks.append(imglink)
        if counter >= int(lim):
            break

    return imglinks


__help__ = """
- /reverse: Does a reverse image search of the media which it was replied to.
"""

__mod_name__ = "Image Lookup"

REVERSE_HANDLER = DisableAbleCommandHandler("reverse",
                                            reverse,
                                            pass_args=True,
                                            admin_ok=True)

dispatcher.add_handler(REVERSE_HANDLER)