当前位置: 首页>>代码示例>>Python>>正文


Python messenger.Messenger类代码示例

本文整理汇总了Python中messenger.Messenger的典型用法代码示例。如果您正苦于以下问题:Python Messenger类的具体用法?Python Messenger怎么用?Python Messenger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Messenger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, appkey, alias, customid, topic, transfer, zigbee_addr):
     self.__logger = logging.getLogger('zigbee_coordinator.Proxy')
     self.__logger.debug('init')
     Messenger.__init__(self, appkey, alias, customid)
     self.transfer = transfer
     self.topic = topic
     self.zigbee_addr = zigbee_addr
开发者ID:yunbademo,项目名称:yunba-smartoffice,代码行数:7,代码来源:zigbee_coordinator.py

示例2: messenger_thread

class messenger_thread(Thread):
    def __init__(self, irc_connection):
        self.messenger = Messenger(irc_connection)
        Thread.__init__(self)
        
    def run(self):
        self.messenger.run_loop()
开发者ID:rwgeaston,项目名称:silly-IRC-bots,代码行数:7,代码来源:generic_bot.py

示例3: __init__

    def __init__(self, appkey, alias, customid, gpio_num):
        self.__logger = logging.getLogger('power_plug.PowerPlug')
        self.__logger.debug('init')
        Messenger.__init__(self, appkey, alias, customid)

        self.gpio_num = gpio_num
        GPIO.setup(self.gpio_num, GPIO.OUT)
开发者ID:pengwj,项目名称:yunba-smartoffice,代码行数:7,代码来源:power_plug.py

示例4: start

    def start(self, resource):
        """Creates Slack Web and RTM clients for the given Resource
        using the provided API tokens and configuration, then
        connects websocket and listens for RTM events.

        Args:
            resource (dict of Resource JSON): See message payloads:
            https://beepboophq.com/docs/article/resourcer-api
        """
        logger.info('Starting bot for resource: {}'.format(resource))
        if ('resource' in resource and
                'SlackBotAccessToken' in resource['resource']):
            res_access_token = resource['resource']['SlackBotAccessToken']
            self.clients = SlackClients(res_access_token)

        if self.clients.rtm.rtm_connect():
            logging.info(
                u'Connected {} to {} team at https://{}.slack.com'.format(
                    self.clients.rtm.server.username,
                    self.clients.rtm.server.login_data['team']['name'],
                    self.clients.rtm.server.domain
                )
            )

            msg_writer = Messenger(self.clients)

            # Random markov here
            markov_chain = Markov(3, msg_writer)

            config_manager.start_config_loader()

            event_handler = RtmEventHandler(
                self.clients, msg_writer, markov_chain
            )
            time_event_handler = TimeTriggeredEventManager(
                self.clients, msg_writer, markov_chain
            )

            os.chmod('./scripts/make_config.sh', 0755)

            while self.keep_running:
                for event in self.clients.rtm.rtm_read():
                    try:
                        event_handler.handle(event)
                    except:
                        err_msg = traceback.format_exc()
                        logging.error('Unexpected error: {}'.format(err_msg))
                        msg_writer.write_error(err_msg, event['channel'])
                        continue

                self._auto_ping(time_event_handler)
                time.sleep(.1)
        else:
            logger.error(
                'Failed to connect to RTM client with token: {}'.format(
                    self.clients.token
                )
            )
开发者ID:ianadmu,项目名称:starter-python-bot,代码行数:58,代码来源:slack_bot.py

示例5: client_thread

def client_thread(conn):
    current_state = WAITING_TO_START_GAME
    messenger = Messenger(conn)
    while current_state is not GAME_OVER:
        if current_state is WAITING_TO_START_GAME:
            game = init_game(messenger)
            current_state = WAITING_FOR_MOVE
        elif current_state is WAITING_FOR_MOVE:
            messenger.send( str (game.incorrect + game.correct) );
            letter = messenger.read()
            if game.already_guessed(letter):
                reply = "You've already guessed %r." % letter
            else:
                game.guess_letter(letter)
                reply = str(game)

            if game.gameover:
                current_state = WAITING_TO_PLAY_AGAIN
            messenger.send(reply)
            messenger.send(str(game.gameover))
        elif current_state is WAITING_TO_PLAY_AGAIN:
            play_again = messenger.read()
            if play_again == "play":
                current_state = WAITING_TO_START_GAME
            elif play_again == "quit":
                current_state = GAME_OVER

    conn.close()
开发者ID:RealStyle12,项目名称:hangman,代码行数:28,代码来源:server.py

示例6: authenticate_as_client

    def authenticate_as_client(self, session_socket):
        # authenticates an external server connected via session_socket

        iv = self.receive_iv(session_socket)
        master_encrypter = Encrypter(self.master_key, iv)
        m = Messenger(session_socket, master_encrypter, self.continueHandler)

        client_challenge = genStr(CHALLENGE_LENGTH)
        client_challenge_hash = str(create_key(client_challenge))
        hash_len = len(client_challenge_hash)
        secretA = generateAorB()
        publicA = pow(g, secretA, p)
        m.send(client_challenge + str(publicA))

        response = m.recv()
        while not response:
            response = m.recv()

        if response[:hash_len] != client_challenge_hash:
            m.close()
            raise Exception('client could not authenticate')

        server_challenge_hash = str(create_key(response[hash_len:hash_len + CHALLENGE_LENGTH]))
        m.send(server_challenge_hash)
        public_b = int(response[hash_len + CHALLENGE_LENGTH:])
        self.log.info('g^b mod p is {}'.format(public_b))
        session_key = create_key(str(pow(public_b, secretA, p)))
        self.log.info('Session key generated by the client is {}'.format(session_key))

        session_encrypter = Encrypter(session_key, iv)
        session_m = Messenger(session_socket, session_encrypter, self.continueHandler)

        self._messenger = session_m
开发者ID:Anna-Gudimova,项目名称:CPEN-442,代码行数:33,代码来源:sessionmanager.py

示例7: check_schedule

    def check_schedule(self, localtime):
        client = Client()

        for volume in client.get_volumes():
            try:
                self._check_volume_schedule(localtime, volume)
            except:
                error_msg = 'Scheduler failed to check volume schedule. %r' % {
                    'volume_id': volume.id
                }
                logger.exception(error_msg)
                msg = Messenger(volume)
                msg.send('%s\n\n%s' % (error_msg, traceback.format_exc()))
开发者ID:drivnal,项目名称:drivnal,代码行数:13,代码来源:scheduler.py

示例8: message_sender

 def message_sender(self):
     self.message_collector()
     msg = "%d messages waiting to be sent" % len(self.waiting_messages)
     log.info(msg)
     print >>sys.stdout, msg
     sent_list = []
     for message in self.waiting_messages:
         sender = Messenger([message])
         sender.check_config("smsleopard")
         sent_msg = sender.send_sms()[0]
         sent_list.extend(sent_msg)
     msg = "%d sent messages" % len(sent_list)
     log.info(msg)
     for sent in sent_list:
         self.db.update_outbox(sent)
开发者ID:CBinyenya,项目名称:cmsserver,代码行数:15,代码来源:cron.py

示例9: __init__

    def __init__(self, appkey, alias, customid, file, presence, like):
        self.__logger = logging.getLogger('stat.Stat')
        self.__logger.debug('init')
        Messenger.__init__(self, appkey, alias, customid)

        self.file = file

        self.data = {}
        self.data['presence'] = presence
        self.data['like'] = like

        if presence != 0 or like != 0:
            self.write_data()
        else:
            self.read_data()
开发者ID:lichunjing,项目名称:yunba-live-video,代码行数:15,代码来源:stat.py

示例10: __init__

 def __init__(self, name='alex', nevts=100, evtfreq=100):
     """ Alex class
     It is the main driver application
     It has a list of algorithms that runs in sequence for a given number of events 
     It has a dictionary of services to be set into each algorithm
     It has a dictionary with run information and event information (clean each event) to be set into in each alorithm
     """
     self.name = name # name of the application 
     self.ievt = 0 # current number of event processed
     self.nevts = nevts # number of events to run
     self.evtfreq = evtfreq # frequency to print event number in log
     self.counters = {}
     self.algs = [] # list of algorithms to run
     self.svcs = {} # dictionary with the services
     # primordial msg service
     self.msg = Messenger(name='msg') 
     self.addsvc(self.msg) # add msg service 
     # primordial request service (handle errrors, abort/end of job requets)
     self.req = RequestSvc(name='req',al=self) 
     self.addsvc(self.req) # add request service
     # event data service
     self.evt = DataSvc(name='evt')
     self.addsvc(self.evt) # add event data service
     self.exports = ['msg','req','evt'] # services to export to algorithms
     return 
开发者ID:nextsw,项目名称:alex,代码行数:25,代码来源:alex.py

示例11: __init__

    def __init__(self, secrets):
        self.trade_params = secrets["tradeParameters"]
        self.pause_params = secrets["pauseParameters"]

        self.Bittrex = Bittrex(secrets)
        self.Messenger = Messenger(secrets)
        self.Database = Database()
开发者ID:ilya0,项目名称:Crypto-Trading-Bot,代码行数:7,代码来源:trader.py

示例12: start

    def start(self, resource):
        """Creates Slack Web and RTM clients for the given Resource
        using the provided API tokens and configuration, then connects websocket
        and listens for RTM events.

        Args:
            resource (dict of Resource JSON): See message payloads - https://beepboophq.com/docs/article/resourcer-api
        """

        logger.debug("Python Version: " + sys.version)
        logging.info('Starting bot for resource: {}'.format(resource))
        if 'resource' in resource and 'SlackBotAccessToken' in resource['resource']:
            res_access_token = resource['resource']['SlackBotAccessToken']
            self.clients = SlackClients(res_access_token)

        if self.clients.rtm.rtm_connect():
            logging.info(u'Connected {} to {} team at https://{}.slack.com'.format(
                self.clients.rtm.server.username,
                self.clients.rtm.server.login_data['team']['name'],
                self.clients.rtm.server.domain))

            msg_writer = Messenger(self.clients)
            event_handler = RtmEventHandler(self.clients, msg_writer)

            while self.keep_running:
                for event in self.clients.rtm.rtm_read():
                    try:
                        event_handler.handle(event)
                    except:
                        err_msg = traceback.format_exc()
                        logging.error('Unexpected error: {}'.format(err_msg))
                        msg_writer.write_error(event['channel'], err_msg)
                        continue

                self._auto_ping()
                time.sleep(.1)

        else:
            logger.error('Failed to connect to RTM client with token: {}'.format(self.clients.token))
开发者ID:davenewham,项目名称:starter-python-bot,代码行数:39,代码来源:slack_bot.py

示例13: authenticate_as_server

    def authenticate_as_server(self, session_socket):
        # authenticates an external client connected via session_socket

        iv = self.generate_and_send_iv(session_socket) # the server should generate a random iv

        master_encrypter = Encrypter(self.master_key, iv)
        m_messenger = Messenger(session_socket, master_encrypter, self.continueHandler)

        secret_b = generateAorB()
        public_b = str(pow(g, secret_b, p))
        server_challenge = genStr(CHALLENGE_LENGTH)
        server_challenge_hash = str(create_key(server_challenge))

        response = m_messenger.recv()
        while not response:
            response = m_messenger.recv()

        client_challenge = response[:CHALLENGE_LENGTH]
        client_challenge_hash = str(create_key(client_challenge))
        public_a = response[CHALLENGE_LENGTH:]
        self.log.info('publicA is {}'.format(public_a))
        m_messenger.send(client_challenge_hash + server_challenge + public_b)
        session_key = create_key(str(pow(int(public_a), secret_b, p)))
        self.log.info('session key is {}'.format(session_key))

        response = m_messenger.recv()
        while not response:
            response = m_messenger.recv()

        if response != server_challenge_hash:
            self.log.warn('Client could not be authenticated. Session will be terminated!')
            m_messenger.close()
        else:
            print('Server Authentication Successful!!!')

        session_encrypter = Encrypter(session_key, iv)
        self._messenger = Messenger(session_socket, session_encrypter, self.continueHandler)
开发者ID:Anna-Gudimova,项目名称:CPEN-442,代码行数:37,代码来源:sessionmanager.py

示例14: __init__

    def __init__(self):
        super().__init__()
        self.connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.protocol("WM_DELETE_WINDOW", lambda: destroy_all(self.connection, self))
        self.title("Chat Client")

        self.length_struct = struct.Struct("!I")
        self.messenger = Messenger(self.connection, self.length_struct)

        self.username = ""
        self.password = ""

        self.connect = ConnectScreen(self, self.connect_to_server)
        self.login = LoginScreen(self, self.check_data)
        self.chat = ChatScreen(self, self.handle_out_going)

        self.connect.pack()
        self.connect.pack_children()
开发者ID:StaticFuzz,项目名称:PythonChat,代码行数:18,代码来源:client.py

示例15: __init__

  def __init__(self):
    super(Registry, self).__init__()

    # Set up YAML parser for optional config file
    self.config_path = path("cosmid.yaml")
    self.config = ConfigReader(self.config_path)

    # Extract stuff from config
    self.email = self.config.find("email")

    # Path to resource storage directory
    self.directory = path(self.config.find("directory", default="resources"))

    # Load history file consisting of already downloaded resources
    self.history_path = path(self.directory + "/.cosmid.yaml")
    self.history = HistoryReader(self.history_path)

    # Set up a :class:`cosmid.messenger.Messenger`
    self.messenger = Messenger("cosmid")
开发者ID:jrherr,项目名称:cosmid,代码行数:19,代码来源:core.py


注:本文中的messenger.Messenger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。