Changeset 2533d10


Ignore:
Timestamp:
2015-05-06T20:58:51Z (10 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Children:
e9face7
Parents:
6f903c3
Message:

Very limited test RSS plugin. I'll try NewsBlur instead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/implugin.py

    r6f903c3 r2533d10  
    1010import time
    1111
     12import feedparser
     13
    1214# List of functions an IM plugin can export. This library will indicate to
    1315# BitlBee which functions are actually implemented so omitted features
    1416# will be disabled, but note that some/many functions are simply mandatory.
     17# (Currently login/-out, buddy_msg, add/remove_buddy.)
    1518SUPPORTED_FUNCTIONS = [
    1619        'login', 'keepalive', 'logout', 'buddy_msg', 'set_away',
     
    4346        # Supported away states. If your protocol supports a specific set of
    4447        # away states, put them in a list in this variable.
    45         AWAY_STATES = ["Away", "Busy"] #None
     48        AWAY_STATES = None
    4649       
    4750        # Filled in during initialisation:
     
    6871                self.bitlbee_version = bee["version"]
    6972                self.bitlbee_version_str = bee["version_str"]
     73
     74                self.feeds = {}
     75
    7076                # TODO: See how to call into the module here.
    7177                return {
     
    101107
    102108        def add_buddy(self, handle, group):
    103                 print "%s is my new best friend in %s \o/" % (handle, group)
    104                 self.bee.add_buddy(handle, group)
    105                 self.bee.buddy_status(handle, 5, "Friend", "Best friend!")
    106                 print self.bee.bee_user_by_handle(handle)
    107                 print self.bee.set_setstr("test", handle)
    108                 print self.bee.set_reset("test")
     109                self.bee.add_buddy(handle, None)
     110                self.feeds[handle] = {
     111                        "url": handle,
     112                        "seen": set(),
     113                }
    109114       
    110         def set_away(self, state, message):
    111                 print "You're a slacker: %s (%r)" % (state, message)
     115        def buddy_msg(self, handle, msg, flags):
     116                feed = self.feeds[handle]
     117                cmd = re.split(r"\s+", msg)
     118                if cmd[0] == "list":
     119                        fp = feedparser.parse(handle)
     120                        for art in fp.entries:
     121                                line = "%(title)s <%(link)s>" % art
     122                                ts = 0
     123                                if "updated_parsed" in art:
     124                                        ts = int(time.mktime(art.updated_parsed))
     125                                self.bee.buddy_msg(handle, line, 0, ts)
     126                                feed["seen"].add(art.id)
    112127       
    113128        def set_set(self, setting, value):
Note: See TracChangeset for help on using the changeset viewer.