Exemple #1
0
    def SendTaskList(self, task_id, task_size, task_status, task_title, download_size, upload_size, download_speed, upload_speed):
        log.info("Task Noti")
        bot = bothandler.BotHandler().instance().bot

        if bot == None:
            log.info("Bot instance is none")
            return

        log.info('Task Detail : %s, %s, %s, %s, %s, %s, %s, %s' % ( task_id, task_title, CommonUtil.hbytes(task_size), self.StatusTranslate(task_status), CommonUtil.hbytes(download_size), CommonUtil.hbytes(upload_size), CommonUtil.hbytes(download_speed), CommonUtil.hbytes(upload_speed) ) )
        msg = self.lang.GetBotHandlerLang('noti_task_list') % ( task_id, task_title, CommonUtil.hbytes(task_size), self.StatusTranslate(task_status), CommonUtil.hbytes(download_size), CommonUtil.hbytes(upload_size), CommonUtil.hbytes(download_speed), CommonUtil.hbytes(upload_speed) )
        self.SendNotifyMessage(msg)
Exemple #2
0
    def SendNotifyMessage(self, msg, ParseMode = None):
        noti_list = self.cfg.GetNotifyList()

        bot = bothandler.BotHandler().instance().bot

        for chat_id in noti_list:
            if ParseMode == 'mark':
                bot.sendMessage(chat_id, msg, parse_mode = telegram.ParseMode.MARKDOWN)
            elif ParseMode == 'html':
                bot.sendMessage(chat_id, msg, parse_mode = telegram.ParseMode.HTML)
            else:
                bot.sendMessage(chat_id, msg)
Exemple #3
0
    def SendStatistic(self, download_speed, upload_speed):
        log.info("Statistic Noti")
        bot = bothandler.BotHandler().instance().bot

        if bot == None:
            log.info("Bot instance is none")
            return

        log.info('Statistic : %s, %s' % ( CommonUtil.hbytes(download_speed), CommonUtil.hbytes(upload_speed) ) )
        msg = self.lang.GetBotHandlerLang('noti_statistic') % ( CommonUtil.hbytes(download_speed), CommonUtil.hbytes(upload_speed) )
        self.SendNotifyMessage(msg)
        return
Exemple #4
0
    def TaskNotiCallback(self, task_id, title, size, user, status):
        log.info("Task Noti")
        bot = bothandler.BotHandler().instance().bot

        if bot == None:
            log.info("Bot instance is none")
            return

        log.info('Task Monitor : %s, %s, %s, %s, %s' % (task_id, title, CommonUtil.hbytes(size), user, status) )
        #msg = '*상태* : %s\n*이름* : %s\n*크기* : %s\n*사용자* : %s' % ( self.StatusTranslate(status), title, CommonUtil.hbytes(size), user)
        msg = self.lang.GetBotHandlerLang('noti_torrent_status') % ( self.StatusTranslate(status), title, CommonUtil.hbytes(size), user)
        #self.SendNotifyMessage(msg, ParseMode = 'mark')
        self.SendNotifyMessage(msg)
Exemple #5
0
def main():

    # Signal 예외 처리
    # signal Register
    signal.signal(signal.SIGTERM, signal_term_handler)
    signal.signal(signal.SIGABRT, signal_handler)
    signal.signal(signal.SIGSEGV, signal_handler)
    signal.signal(signal.SIGHUP, signal_handler)

    # BotConfig Init
    BotConfig.BotConfig().instance()

    #synods.SynoDownloadStation().instance().Login()

    bot = bothandler.BotHandler().instance()

    bot.InitBot()

    log.info("Bot Exit")
Exemple #6
0
import logging

from flask import Flask, request

import bothandler
import nexmohandler


bot_handler = bothandler.BotHandler()
sms_handler = nexmohandler.NexmoHandler()

app = Flask(__name__)


@app.route('/')
def hello_world():
    return 'Hello, World!'


@app.route('/api/sms/receive')
def api_sms_receive():
    parsed = sms_handler.parse_request( request.values )
    messages = bot_handler.handle( parsed['message'] )
    for message_out in messages:
        r = sms_handler.send_message(
            to_number = parsed['originating_number'],
            message = message_out, 
            from_name = parsed['receiving_number']
        )
        logging.info( r )
    return "OK!"