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


Python Message.params方法代码示例

本文整理汇总了Python中message.Message.params方法的典型用法代码示例。如果您正苦于以下问题:Python Message.params方法的具体用法?Python Message.params怎么用?Python Message.params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在message.Message的用法示例。


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

示例1: die

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import params [as 别名]
 def die(self, nick, channel, details):
     if not self.check_permissions(nick, channel, 'a'):
         return self.error_message(nick, channel, 'Admin rights required')
     m = Message()
     m.command = 'PRIVMSG'
     m.params = [nick, 'Aaaieeee!']
     self.connection.send(m)
     m.command = 'QUIT'
     m.params = ['We out']
     self.connection.send(m)
开发者ID:colourblind,项目名称:BeastBot,代码行数:12,代码来源:core.py

示例2: join

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import params [as 别名]
 def join(self, nick, channel, details):
     if len(details) < 1:
         return self.error_message(nick, channel, 'Usage: !join CHANNEL')
     m = Message()
     m.command = 'JOIN'
     if details[0].startswith('#'):
         m.params = [details[0]]
     else:
         m.params = ['#' + details[0]]
     self.connection.send(m)
开发者ID:colourblind,项目名称:BeastBot,代码行数:12,代码来源:core.py

示例3: logout

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import params [as 别名]
 def logout(self, nick, channel, details):
     u = db.User(nick=nick)
     m = Message()
     m.command = 'PRIVMSG'
     if u.new:
         m.params = [nick, 'Unable to match nick to user']
     else:
         u.logout()
         m.params = [nick, 'Done']
     self.connection.send(m)
开发者ID:colourblind,项目名称:BeastBot,代码行数:12,代码来源:core.py

示例4: uptime

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import params [as 别名]
 def uptime(self, nick, channel, details):
     replyto = nick if channel == None else channel
     td = datetime.now() - self.startdate
     total_seconds = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
     m = Message()
     m.command = 'PRIVMSG'
     m.params = [replyto, 'Up since ' + str(self.startdate)]
     self.connection.send(m)
     m.params = [replyto, 'That\'s ' + str(total_seconds) + ' seconds']
     self.connection.send(m)
开发者ID:colourblind,项目名称:BeastBot,代码行数:12,代码来源:core.py

示例5: leave

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import params [as 别名]
 def leave(self, nick, channel, details):
     # TODO: check chanop status
     if channel == None and len(details) == 0:
         return self.error_message(nick, channel, 'Usage: !leave CHANNEL')
     m = Message()
     m.command = 'PART'
     if len(details) > 0:
         m.params = [details[0]]
     elif channel != None:
         m.params = [channel]
     self.connection.send(m)
开发者ID:colourblind,项目名称:BeastBot,代码行数:13,代码来源:core.py

示例6: handle

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import params [as 别名]
    def handle(self, message):
        if message.command == "PING":
            # respond quick before we get booted!
            m = Message()
            m.command = "PONG"
            m.params = message.params
            self.connection.send(m)
        elif message.command == "QUIT":
            # user left. Log them out if need be
            u = db.User(nick=message.sender)
            u.logout()
        elif message.command == "NICK":
            # nick updated. Chase them!
            u = db.User(nick=message.sender)
            u.change_nick(message.params[0])
        elif message.command == "PRIVMSG" and message.params[1].startswith(self.settings["command_prefix"]):
            # palm it off to the plugins
            for plugin in self.plugins:
                if plugin.handle(message):
                    break

        channel = None
        if message.params[0].startswith("#"):
            channel = message.params[0]
        db.log_message(message.command, message.sender, channel, " ".join(message.params))
开发者ID:colourblind,项目名称:BeastBot,代码行数:27,代码来源:beastbot.py

示例7: wiki

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import params [as 别名]
    def wiki(self, nick, channel, params):
        if len(params) < 1:
            return;

        replyto = nick if channel == None else channel
        qs = { 
            'action': 'query',
            'prop': 'revisions',
            'rvprop': 'content',
            'format': 'xml',
            'titles': ' '.join(params)
        }
        url = 'http://en.wikipedia.org/w/api.php?' + urllib.urlencode(qs)

        xml = ElementTree.parse(urllib.urlopen(url))
        result = xml.findtext('.//rev')

        if result is not None:
            result = self.deugly_wikimedia(result)
        else:
            result = 'Couldn\'t find it :('
            
        m = Message()
        m.command = 'PRIVMSG'
        m.params = [replyto, result]
        self.connection.send(m)
开发者ID:colourblind,项目名称:BeastBot,代码行数:28,代码来源:lookup.py

示例8: register

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import params [as 别名]
 def register(self, nick, channel, details):
     if len(details) < 2:
         return self.error_message(nick, channel, 'Usage: !register USERNAME PASSWORD')
     if channel != None:
         return self.error_message(nick, channel, 'USE PRIVATE MESSAGES FOR REGISTERING AND LOGGING IN (idiot)')
     
     m = Message()
     m.command = 'PRIVMSG'
     u = db.User(details[0])
     if u.new:
         u.username = details[0]
         u.setpassword(details[1])
         u.save()
         m.params = [nick, 'Done']
     else:
         m.params = [nick, 'User already exists']
     self.connection.send(m)
开发者ID:colourblind,项目名称:BeastBot,代码行数:19,代码来源:core.py

示例9: finduser

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import params [as 别名]
 def finduser(self, nick, channel, details):
     if len(details) < 1:
         return;
     users = db.finduser(details[0])
     m = Message()
     m.command = 'PRIVMSG'
     m.params = [nick, '']
     for row in users:
         m.params[1] = str(row)
         self.connection.send(m)
开发者ID:colourblind,项目名称:BeastBot,代码行数:12,代码来源:core.py

示例10: promote

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import params [as 别名]
 def promote(self, nick, channel, details):
     if channel == None and len(details) == 0:
         return self.error_message(nick, channel, 'Usage: !promote CHANNEL')
     u = db.User(nick=nick)
     m = Message()
     if u.new:
         m.command = 'PRIVMSG'
         m.params = [nick, 'Please log in']
         self.connection.send(m)
     else:
         if channel == None:
             channel = details[0] if details[0].startswith('#') else '#' + details[0]
         perms = u.getpermissions(channel)
         if perms != None:
             m.command = 'MODE'
             m.params = [channel, '+' + perms, nick]
             self.connection.send(m)
         else:
             m.command = 'PRIVMSG'
             m.params = [nick, 'You have no rights for this channel']
             self.connection.send(m)
开发者ID:colourblind,项目名称:BeastBot,代码行数:23,代码来源:core.py

示例11: perms

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import params [as 别名]
    def perms(self, nick, channel, details):
        if len(details) == 0:
            return self.error_message(nick, channel, 'Usage: !perms USER [CHANNEL] [PERMISSIONS]')
        u = db.User(details[0])
        if u.new:
            return self.error_message(nick, channel, 'Could not find user')

        m = Message()
        m.command = 'PRIVMSG'
        if len(details) == 1:
            m.params = [nick, str(u.getallpermissions())]
        elif len(details) == 2:
            m.params = [nick, str(u.getpermissions(details[1]))]
        elif len(details) == 3:
            target_channel = details[1] if details[1].startswith('#') else '#' + details[1]
            if self.check_permissions(nick, target_channel, 'o'):
                u.setpermissions(target_channel, details[2])
                m.params = [nick, 'Done']
            else:
                return self.error_message(nick, channel, 'You do not have the required permissions for this channel')
        self.connection.send(m)
开发者ID:colourblind,项目名称:BeastBot,代码行数:23,代码来源:core.py

示例12: login

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import params [as 别名]
    def login(self, nick, channel, details):
        if len(details) < 2:
            return self.error_message(nick, channel, 'Usage: !login USERNAME PASSWORD')
        if channel != None:
            return self.error_message(nick, channel, 'USE PRIVATE MESSAGES FOR REGISTERING AND LOGGING IN (idiot)')
        u = db.User(nick=nick)
        if not u.new:
            return self.error_message(nick, channel, 'You are already logged in as ' + u.nick)            

        m = Message()
        m.command = 'PRIVMSG'
        u = db.authenticate(details[0], details[1])
        if u == None:
            m.params = [nick, 'Login failed']
        else:
            if len(u.nick) > 0:
                m.params = [nick, 'Already logged in']
            else:
                u.nick = nick
                u.last_login = datetime.now()
                u.save()
                m.params = [nick, 'Login succeeded']
        self.connection.send(m)
开发者ID:colourblind,项目名称:BeastBot,代码行数:25,代码来源:core.py

示例13: seen

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import params [as 别名]
 def seen(self, nick, channel, params):
     # TODO: case sensitivity?
     if len(params) == 0:
         return self.error_message(nick, channel, 'Usage: !seen NICK')
 
     result = db.last_seen(params[0])
     
     m = Message()
     m.command = 'PRIVMSG'
     m.params = [nick if channel == None else channel]
     if result is None:
         m.params.append('Never seen {0}'.format(params[0]))
     else:
         m.params.append('{0} was last seen at {1}'.format(params[0], result))
     self.connection.send(m)
开发者ID:colourblind,项目名称:BeastBot,代码行数:17,代码来源:core.py

示例14: define

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import params [as 别名]
 def define(self, nick, channel, params):
     if len(params) < 1:
         return;
         
     replyto = nick if channel == None else channel
     url = 'http://services.aonaware.com/DictService/DictService.asmx/DefineInDict'
     body = urllib.urlencode({'dictId' : 'wn', 'word' : params[0]}) 
     xml = ElementTree.parse(urllib.urlopen(url, body))
    
     namespace = '{http://services.aonaware.com/webservices/}'
     result = xml.findtext('.//{0}Definition/{0}WordDefinition'.format(namespace))
 
     m = Message()
     m.command = 'PRIVMSG'
     
     lines = result.split('\n')
     for i in range(min(len(result), 5)):
         m.params = [replyto, lines[i]]
         self.connection.send(m)
开发者ID:colourblind,项目名称:BeastBot,代码行数:21,代码来源:lookup.py

示例15: weather

# 需要导入模块: from message import Message [as 别名]
# 或者: from message.Message import params [as 别名]
    def weather(self, nick, channel, params):
        # ditch this for now. The API appears to have gone away
        return
    
        if len(params) < 1:
            return;

        replyto = nick if channel == None else channel
        location = ' '.join(params)
        url = 'http://www.google.com/ig/api?' + urllib.urlencode({'weather' : location})
        xml = ElementTree.parse(urllib.urlopen(url))
        
        condition = xml.find('.//current_conditions/condition').attrib['data']
        temp = (xml.find('.//current_conditions/temp_c').attrib['data'], xml.find('//temp_f').attrib['data'])
        wind = xml.find('.//current_conditions/wind_condition').attrib['data']
        report = '{0} is currently {1} ({2}C {3}F) {4}'.format(location, condition, temp[0], temp[1], wind)
        
        m = Message()
        m.command = 'PRIVMSG'
        m.params = [replyto, report]
        self.connection.send(m)
开发者ID:colourblind,项目名称:BeastBot,代码行数:23,代码来源:lookup.py


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