aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlas Oliva <blasoliva@gmail.com>2015-01-20 23:17:18 -0300
committerBlas Oliva <blasoliva@gmail.com>2015-01-20 23:17:18 -0300
commit02484c17e66985c6e3dd3463bfd7b9b15f52b339 (patch)
tree926f79472357944b29a192fb5d90dfbffa1d86b6
parent192e4f1d2c987f79c93504ef316864048282f27f (diff)
downloadreebot-02484c17e66985c6e3dd3463bfd7b9b15f52b339.tar.gz
reebot-02484c17e66985c6e3dd3463bfd7b9b15f52b339.zip
some little things
-rwxr-xr-xrbot.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/rbot.py b/rbot.py
index 5f853a3..558e305 100755
--- a/rbot.py
+++ b/rbot.py
@@ -27,6 +27,7 @@ def main():
27class rBot: 27class rBot:
28 def __init__(self, db): 28 def __init__(self, db):
29 """ IRC objects constructor """ 29 """ IRC objects constructor """
30
30 # MongoDB connection 31 # MongoDB connection
31 self.db = db 32 self.db = db
32 33
@@ -38,7 +39,7 @@ class rBot:
38 # Join channels and send welcome message 39 # Join channels and send welcome message
39 for channel in channels_list: 40 for channel in channels_list:
40 self.server.join( channel ) 41 self.server.join( channel )
41 self.sendmessage( channel, messages['che'] ) 42 self.sendmessage( channel, messages['che'] )
42 43
43 # Register handlers 44 # Register handlers
44 self.irc.add_global_handler( 'ping', self.ponger, -42 ) 45 self.irc.add_global_handler( 'ping', self.ponger, -42 )
@@ -89,14 +90,15 @@ class rBot:
89 self.sendmessage( target, messages['hello'] + source ) 90 self.sendmessage( target, messages['hello'] + source )
90 91
91 def handlejoin(self, connection, event): 92 def handlejoin(self, connection, event):
92 """ Handle channel join 93 """ Handle channel join
93 94
94 source -- user who joined the channel 95 source -- user who has joined the channel
95 """ 96 """
96 source = event.source().split( '!' ) [0] 97 source = event.source().split( '!' ) [0]
97 self.sendmessage( source, messages['welcome'] ) 98 self.sendmessage( source, messages['welcome'] )
98 99
99 def feed_refresh(self): 100 def feed_refresh(self):
101 """ Read feeds and sends them to the channel """
100 102
101 msgqueue = [] 103 msgqueue = []
102 104
@@ -114,6 +116,7 @@ class rBot:
114 + " | " + feeds.feed.title 116 + " | " + feeds.feed.title
115 + " > " + entry.title 117 + " > " + entry.title
116 + " : " + entry.link ) 118 + " : " + entry.link )
119 # Update feeds log in the database
117 self.db.log.insert( { "url" : entry.link } ) 120 self.db.log.insert( { "url" : entry.link } )
118 121
119 while len( msgqueue ) > 0: 122 while len( msgqueue ) > 0: