Beispiel #1
0
def main():
    def stop_and_restart():
        updater.stop()
        os.execl(sys.executable, sys.executable, *sys.argv)

    def restart(update, context):
        context.bot.sendMessage(update.effective_chat.id, "Rebooted ✨")
        Thread(target=stop_and_restart).start()

    restart_handler = CommandHandler("reboot",
                                     restart,
                                     filters=Filters.user(DEV_ID))
    start_handler = CommandHandler("start", start)
    help_funcs_handler = CallbackQueryHandler(h_for_funcs, pattern=r"h_")
    help_handler = CallbackQueryHandler(help_button, pattern=r"help")
    back_btn_handler = CallbackQueryHandler(back_btn, pattern=r"back_btn")

    dp.add_handler(restart_handler)
    dp.add_handler(start_handler)
    dp.add_handler(help_funcs_handler)
    dp.add_handler(help_handler)
    dp.add_handler(back_btn_handler)

    LOG.info("%s", BANNER)

    # Start the bot.
    updater.start_polling(timeout=15, read_latency=4)
    updater.idle()
Beispiel #2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# MIT License
# Copyright (c) 2020 Stɑrry Shivɑm // This file is part of AcuteBot
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.



from acutebot import LOG
from os.path import dirname, basename, isfile
import glob

def list_modules():
    mod_paths = glob.glob(dirname(__file__) + "/*.py")
    all_modules = [basename(f)[:-3] for f in mod_paths if isfile(f)
                   and f.endswith(".py")
                   and not f.endswith('__init__.py')]
    return all_modules

ALL_FUNCS = sorted(list_modules())
LOG.info("Modules loaded: %s", str(ALL_FUNCS))
__all__ = ALL_FUNCS + ["ALL_FUNCS"]