Esempio n. 1
0
def apply_options(options):

    global CONF_FILE,\
        num,\
        log,\
        apply_date_to_output,\
        password,\
        username,\
        timeout,\
        verbose,\
        auth_app

    num = options[ACC_NUM_KEY]
    log = options[LOG_FILE_KEY]
    apply_date_to_output = options[DD_KEY]
    password = options[PASSWD_KEY]
    username = options[UNAME_KEY]
    timeout = options[LONG_POOL_TIME_OUT_KEY]
    verbose = options[V_KEY]
    app_name = options[AUTH_APP_KEY]
    try:
        auth_app = vk_auth.vk_app.VKApp[app_name]
        bot_header.v("Using app %s" % app_name)
    except KeyError:
        bot_header.w("app %s not exists. Using WIN app" % app_name)
        auth_app = vk_auth.vk_app.VKApp.WIN
    pass
def main(message, lpt):
    # get id of user
    typing_id = message[1]
    # get user from VK API by id
    user = User.from_json(
        api_request(get_api(lpt=lpt), "users.get",
                    "user_ids=%s" % typing_id)[0])
    # print some message to inform user that someone started typing:)
    bot_header.v("%s started typing..." % user.first_last())
Esempio n. 3
0
 def process(evid, resp, lp_thread_ins):
     # get name of event by id
     method_name = LongPoolEvent(evid).name.lower()
     # execute file in $rootOfProject/long_pool_events/$nameOfMethod
     try:
         exec('from long_pool_events import module_%s' % method_name)
         exec("reload( module_" + method_name + ")")
         exec('module_%s.main(resp, lp_thread_ins)' % method_name)
         # exec("retval = LongPoolEvent.__%s__(evid)" % method_name)
     except ImportError as e:
         bot_header.v(e)
         bot_header.v(
             "---W---[LP] define new file in long_pool_events: module_%s with method 'main'"
             % method_name)
         pass
     except Exception as exc:
         exceptiondata = traceback.format_exc().splitlines()
         exceptionarray = exceptiondata[-1] + " " + exceptiondata[
             -2] + " " + exceptiondata[-3]
         bot_header.w(
             "[LP] Exception in modules %s:\n  | %s Trace:\n  | %s" %
             (method_name, str(exc), str(exceptionarray)))
 def v(self, text):
     bot_header.v("[::AEXEC] %s" % text)
Esempio n. 5
0
 def v(self, text):
     bot_header.v('[::LP] [%s] %s' % (self.account.first_last(), text))