コード例 #1
0
ファイル: events.py プロジェクト: carnage/csbot
    def reply(self, msg, is_verbose=False):
        """Send a reply message.

        All plugin responses should be via this method.  The :attr:`user` is
        addressed by name if the response is in a channel rather than a private
        chat.  If *is_verbose* is True, the reply is suppressed unless the bot
        was addressed directly, i.e. in private chat or by name in a channel.
        """
        if self.channel == self.protocol.nickname:
            self.protocol.msg(nick(self.user), msg)
        elif self.direct or not is_verbose:
            self.protocol.msg(self.channel,
                              nick(self.user) + ': ' + msg)
コード例 #2
0
ファイル: usertrack.py プロジェクト: barrucadu/csbot
 def account_command(self, e):
     nick_ = e["data"] or nick(e["user"])
     account = self.get_user(nick_)["account"]
     if account is None:
         e.protocol.msg(e["reply_to"], "{} is not authenticated".format(nick_))
     else:
         e.protocol.msg(e["reply_to"], "{} is authenticated as {}".format(nick_, account))
コード例 #3
0
 def account_command(self, e):
     nick_ = e['data'] or nick(e['user'])
     account = self.get_user(nick_)['account']
     if account is None:
         e.reply('{} is not authenticated'.format(nick_))
     else:
         e.reply('{} is authenticated as {}'.format(nick_, account))
コード例 #4
0
ファイル: usertrack.py プロジェクト: BenSimner/csbot
 def account_command(self, e):
     nick_ = e['data'] or nick(e['user'])
     account = self.get_user(nick_)['account']
     if account is None:
         e.reply('{} is not authenticated'.format(nick_))
     else:
         e.reply('{} is authenticated as {}'.format(nick_, account))
コード例 #5
0
    def record_command(self, event):
        """Record the receipt of a new command.
        """
        if not event['message'].startswith(self.bot.config.command_prefix):
            return

        self.record(event, nick(event['user']), event['channel'], 'command',
                    event['message'])
コード例 #6
0
ファイル: core.py プロジェクト: Haegin/csbot-1
 def action(self, user, channel, message):
     self.emit_new('core.message.action', {
         'channel': channel,
         'user': user,
         'message': message,
         'is_private': channel == self.nickname,
         'reply_to': nick(user) if channel == self.nickname else channel,
     })
コード例 #7
0
ファイル: last.py プロジェクト: BenSimner/csbot
 def record_action(self, event):
     """Record the receipt of a new action.
     """
     self.record(event,
                 nick(event['user']),
                 event['channel'],
                 'action',
                 event['message'])
コード例 #8
0
ファイル: whois.py プロジェクト: AbstractBeliefs/csbot
    def set(self, e):
        """Allow a user to associate data with themselves for this channel."""

        ident = self.identify_user(nick(e['user']), e['channel'])
        self.whoisdb.remove(ident)

        ident['data'] = e['data']
        self.whoisdb.insert(ident)
コード例 #9
0
    def whois(self, e):
        """Look up a user by nick, and return what data they have set for
        themselves (or an error message if there is no data)"""
        nick_ = e['data'] or nick(e['user'])
        res = self.whois_lookup(nick_, e['channel'])

        if res is None:
            e.reply('No data for {}'.format(nick_))
        else:
            e.reply('{}: {}'.format(nick_, str(res)))
コード例 #10
0
ファイル: last.py プロジェクト: BenSimner/csbot
    def record_command(self, event):
        """Record the receipt of a new command.
        """
        if not event['message'].startswith(self.bot.config_get('command_prefix')):
            return

        self.record(event,
                    nick(event['user']),
                    event['channel'],
                    'command',
                    event['message'])
コード例 #11
0
ファイル: whois.py プロジェクト: AbstractBeliefs/csbot
    def whois(self, e):
        """Look up a user by nick, and return what data they have set for
        themselves (or an error message if there is no data)"""

        nick_ = e['data'] or nick(e['user'])
        ident = self.identify_user(nick_, e['channel'])
        user = self.whoisdb.find_one(ident)

        if user is None:
            e.protocol.msg(e['reply_to'], 'No data for {}'.format(nick_))
        else:
            e.protocol.msg(e['reply_to'], '{}: {}'.format(nick_, user['data']))
コード例 #12
0
    def tell_command(self, event):
        """
        Stores a message for a user to be delivered when the user is next in
        the channel.

        Usage::

            !tell <user> <message>

        Example::

            > TestUser  [13:37] | !tell Haegin You are awesome.
            > Bot       [13:37] | TestUser, I'll let Haegin know.

        If Haegin is already in the channel the bot should let the user know.
        ::

            > Bot       [13:37] | TestUser, Haegin is here, you can tell them
            >                   | yourself!

        When Haegin next connects to the channel the bot will send him a
        message of the following form::

        > Haegin, "You are awesome." - TestUser (at 13:37)

        TODO:

        - It should be possible to leave a long message (how long is long?).
        - Long messages should be announced in the channel but sent as a PM
        - Implement a private message feature that won't be announced in the
          channel
        - We need to handle messages which are just long enough to fit in one
          message when saved but too long when the citation and time is added.
        """
        print(event.data)
        to_user = event.data[0]
        message = " ".join(event.data[1:])
        from_user = nick(event.user)
        # TODO: this should probably do some i18n but being as the channel is
        # largely in the UK...
        time = event.datetime
        if (self.bot.get_plugin("users.Users").is_online(to_user)):
            event.reply(
                "{} is here, you can tell them yourself.".format(to_user))
        else:
            msg = {
                'message': message,
                'from': from_user,
                'to': to_user,
                'time': time
            }
            self.db.messages.insert(msg)
            event.reply("{}, I'll let {} know.".format(from_user, to_user))
コード例 #13
0
    def record_message(self, event):
        """Record the receipt of a new message.
        """
        # Check if this is an action
        if event['message'].startswith('\x01ACTION'):
            return

        # Check if this is a command
        if event['message'].startswith(self.bot.config.command_prefix):
            return

        self.record(event, nick(event['user']), event['channel'], 'message',
                    event['message'])
コード例 #14
0
ファイル: tell.py プロジェクト: HackSoc/csbot
    def tell_command(self, event):
        """
        Stores a message for a user to be delivered when the user is next in
        the channel.

        Usage::

            !tell <user> <message>

        Example::

            > TestUser  [13:37] | !tell Haegin You are awesome.
            > Bot       [13:37] | TestUser, I'll let Haegin know.

        If Haegin is already in the channel the bot should let the user know.
        ::

            > Bot       [13:37] | TestUser, Haegin is here, you can tell them
            >                   | yourself!

        When Haegin next connects to the channel the bot will send him a
        message of the following form::

        > Haegin, "You are awesome." - TestUser (at 13:37)

        TODO:

        - It should be possible to leave a long message (how long is long?).
        - Long messages should be announced in the channel but sent as a PM
        - Implement a private message feature that won't be announced in the
          channel
        - We need to handle messages which are just long enough to fit in one
          message when saved but too long when the citation and time is added.
        """
        print(event.data)
        to_user = event.data[0]
        message = " ".join(event.data[1:])
        from_user = nick(event.user)
        # TODO: this should probably do some i18n but being as the channel is
        # largely in the UK...
        time = event.datetime
        if (self.bot.get_plugin("users.Users").is_online(to_user)):
            event.reply("{} is here, you can tell them yourself."
                    .format(to_user))
        else:
            msg = {'message': message,
                   'from': from_user,
                   'to': to_user,
                   'time': time}
            self.db.messages.insert(msg)
            event.reply("{}, I'll let {} know.".format(from_user, to_user))
コード例 #15
0
ファイル: last.py プロジェクト: BenSimner/csbot
    def record_message(self, event):
        """Record the receipt of a new message.
        """
        # Check if this is an action
        if event['message'].startswith('\x01ACTION'):
            return

        # Check if this is a command
        if event['message'].startswith(self.bot.config_get('command_prefix')):
            return

        self.record(event,
                    nick(event['user']),
                    event['channel'],
                    'message',
                    event['message'])
コード例 #16
0
ファイル: core.py プロジェクト: Sourceless/csbot
    def irc_JOIN(self, prefix, params):
        """Re-implement ``JOIN`` handler to account for ``extended-join`` info.
        """
        user = prefix
        nick_ = nick(user)
        channel, account, _ = params

        if nick_ == self.nickname:
            self.joined(channel)
        else:
            self.emit_new('core.user.identified', {
                'user': user,
                'account': None if account == '*' else account,
            })
            self.emit_new('core.channel.joined', {
                'channel': channel,
                'user': user,
            })
コード例 #17
0
 def _channel_left(self, e):
     user = self._users[nick(e['user'])]
     user['channels'].discard(e['channel'])
     # Lost sight of the user, can't reliably track them any more
     if len(user['channels']) == 0:
         del self._users[nick(e['user'])]
コード例 #18
0
 def _channel_joined(self, e):
     user = self._users[nick(e['user'])]
     user['channels'].add(e['channel'])
コード例 #19
0
ファイル: example.py プロジェクト: carnage/csbot
 def action(self, event):
     print '[{timestamp}][{event.channel}] * {nick} {event.message}'.format(
             event=event,
             nick=nick(event.user),
             timestamp=event.datetime.strftime('%Y/%m/%d %H:%M'))
コード例 #20
0
 def command(self, event):
     self.pretty_log.info(
         'Command {command} fired by {nick} in channel {channel}'.format(
             command=(event['command'], event['data']),
             nick=nick(event['user']),
             channel=event['channel']))
コード例 #21
0
ファイル: usertrack.py プロジェクト: Sourceless/csbot
 def _channel_left(self, e):
     user = self._users[nick(e['user'])]
     user['channels'].discard(e['channel'])
     # Lost sight of the user, can't reliably track them any more
     if len(user['channels']) == 0:
         del self._users[nick(e['user'])]
コード例 #22
0
ファイル: usertrack.py プロジェクト: barrucadu/csbot
 def _channel_joined(self, e):
     user = self._users[nick(e["user"])]
     user["channels"].add(e["channel"])
コード例 #23
0
 def unset(self, e):
     self.whois_unset(nick(e['user']), channel=e['channel'])
コード例 #24
0
 def setdefault(self, e):
     self.whois_set(nick(e['user']), e['data'], channel=None)
コード例 #25
0
ファイル: usertrack.py プロジェクト: barrucadu/csbot
 def _user_identified(self, e):
     user = self._users[nick(e["user"])]
     user["account"] = e["account"]
コード例 #26
0
ファイル: usertrack.py プロジェクト: Sourceless/csbot
 def _user_quit(self, e):
     # User is gone, remove record
     del self._users[nick(e['user'])]
コード例 #27
0
ファイル: usertrack.py プロジェクト: Sourceless/csbot
 def _user_identified(self, e):
     user = self._users[nick(e['user'])]
     user['account'] = e['account']
コード例 #28
0
 def _user_identified(self, e):
     user = self._users[nick(e['user'])]
     user['account'] = e['account']
コード例 #29
0
 def _user_quit(self, e):
     # User is gone, remove record
     del self._users[nick(e['user'])]
コード例 #30
0
 def notice(self, event):
     self.pretty_log.info('[{channel}] -{nick}- {message}'.format(
         channel=event['channel'],
         nick=nick(event['user']),
         message=event['message']))
コード例 #31
0
 def action(self, event):
     self.pretty_log.info('[{channel}] * {nick} {message}'.format(
         channel=event['channel'],
         nick=nick(event['user']),
         message=event['message']))
コード例 #32
0
ファイル: usertrack.py プロジェクト: Sourceless/csbot
 def _channel_joined(self, e):
     user = self._users[nick(e['user'])]
     user['channels'].add(e['channel'])
コード例 #33
0
 def set(self, e):
     """Allow a user to associate data with themselves for this channel."""
     self.whois_set(nick(e['user']), e['data'], channel=e['channel'])
コード例 #34
0
 def record_action(self, event):
     """Record the receipt of a new action.
     """
     self.record(event, nick(event['user']), event['channel'], 'action',
                 event['message'])
コード例 #35
0
 def unsetdefault(self, e):
     self.whois_unset(nick(e['user']))
コード例 #36
0
 def privmsg(self, event):
     self.pretty_log.info('[{channel}] <{nick}> {message}'.format(
         channel=event['channel'],
         nick=nick(event['user']),
         message=event['message']))