Пример #1
0
def bluelight(update, context: CallbackContext):
    cmd = ['/bin/bash', '/tmp/blue_light.sh']
    ps = subprocess.run(cmd)
    rc = ps.returncode
    if rc != 0:
        err = "`{}` returned `{}`".format(" ".join(cmd), rc)
        update.message.reply_text(err, parse_mode="Markdown")
    else:
        update.message.reply_text("done")
    logger.info("{} set AP light to blue".format(name_user(update)))
Пример #2
0
    def temps(self, hours, update, context: CallbackContext):
        try:
            temps = self._get_temps()
            count = len(temps)
            csv = self.config['temper_sub']['csv_file']

            with BytesIO() as f:
                stream = graphtemps.graph(csv, hours, f, count)
                f.seek(0)
                update.message.reply_photo(f)

            fmt_temps = self._temp_to_string(temps)
            update.message.reply_text(fmt_temps, parse_mode="Markdown")

            asker = name_user(update)
            logger.info(f"{asker} asked for temp ({fmt_temps})".replace(
                "\n", ""))
        except ValueError as e:
            update.message.reply_text(str(e))
            logger.error(e)
Пример #3
0
def ruok(update, context: CallbackContext):
    """A way for me to check if it is alive"""
    logger.info("{} asked me how im ding".format(name_user(update)))
    update.message.reply_text('`imok`', parse_mode='Markdown')
Пример #4
0
def help(update, context: CallbackContext):
    """Send a message when the command /help is issued."""
    update.message.reply_text(help_text)
    logger.info("{} asked me for help".format(name_user(update)))
Пример #5
0
def where(update, context: CallbackContext):
    hostname = "`{}`".format(gethostname())
    update.message.reply_text(hostname, parse_mode='Markdown')
    logger.info("{} asked me where i am".format(name_user(update)))
Пример #6
0
def unknown_help(update, context: CallbackContext):
    logger.info("{} is being rude".format(name_user(update)))
    update.message.reply_text("Unknown command")
    update.message.reply_text(help_text)