コード例 #1
0
ファイル: irc.py プロジェクト: miri64/spline_social
 def get_mentions(conn, channel, interval, posting_api, since_id):
     timestr = lambda sec: time.strftime(
             "%Y-%m-%d %H:%M:%S",
             time.localtime(sec)
         )
     while 1:
         try:
             statuses = posting_api.GetMentions(since_id)
             if len(statuses) > 0 and conn.socket != None:   # if there is a connection
                 since_id = max(statuses, key = lambda s: s.id).id
                 Timeline.update('mentions', since_id)
                 for status in statuses:
                     mention = "@%s: %s (%s, %s)" % \
                             (status.user.screen_name,
                              status.text, 
                              timestr(status.created_at_in_seconds),
                              "https://identi.ca/notice/%d" % status.id
                             )
                     conn.privmsg(channel, mention)
             time.sleep(interval)
         except BaseException, e:
             print 'Critical:', e
コード例 #2
0
ファイル: irc.py プロジェクト: miri64/spline_social
 def do_reply(self, recipient, message):
     if recipient == 'last':
         status_id = Timeline.get_by_name('mentions').since_id
     elif recipient.find('@') == 0:
         reply = "Direct user answer is not implemented yet."
         self._do_reply(reply)
         return
     elif re.match('^[0-9]+$', recipient):
         status_id = int(recipient)
     else:
         raise CommandHandler.UsageError('reply')
     status = self.bot.posting_api.GetStatus(status_id)
     self.do_post(message, status_id)
コード例 #3
0
ファイル: irc.py プロジェクト: miri64/spline_social
 def __init__(
         self,
         posting_api,
         channel,
         server,
         port=6667,
         ssl=False,
         nickname='spline_social',
         short_symbols='',
         mention_interval=120,
         since_id=0
     ):
     SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname)
     self.channel = channel
     self.ssl = ssl
     self.posting_api = posting_api
     self.short_symbols = short_symbols
     self.mention_interval = mention_interval
     self.since_id = Timeline.update('mentions', since_id)
     self.mention_grabber = None