cleanup; use a more reasonable config{} definition method
This commit is contained in:
10
bot.py
10
bot.py
@@ -26,7 +26,6 @@ def message_handler(connect_object, message_node):
|
|||||||
typ='groupchat'
|
typ='groupchat'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# send_msg('hello %s!' % msg_from)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print '%20s: %s' %(msg_from, msg_body)
|
print '%20s: %s' %(msg_from, msg_body)
|
||||||
@@ -44,15 +43,6 @@ client.RegisterHandler('message', message_handler)
|
|||||||
|
|
||||||
client.send(xmpp.Presence(to=(conf('room') + '/' + conf('nick'))))
|
client.send(xmpp.Presence(to=(conf('room') + '/' + conf('nick'))))
|
||||||
|
|
||||||
def send_msg(msg='''wee, I'm a native bot.'''):
|
|
||||||
client.send(
|
|
||||||
xmpp.protocol.Message(
|
|
||||||
to=conf('room'),
|
|
||||||
body=msg,
|
|
||||||
typ='groupchat'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
while (t + time.time()) < 30:
|
while (t + time.time()) < 30:
|
||||||
client.Process(1)
|
client.Process(1)
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ if '__main__' == __name__:
|
|||||||
print '''don't try running this'''
|
print '''don't try running this'''
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
config = {}
|
config = {
|
||||||
config['jid'] = ''
|
'jid': '',
|
||||||
config['password'] = ''
|
'password': '',
|
||||||
config['room'] = ''
|
'room': '',
|
||||||
config['nick'] = ''
|
'nick': '',
|
||||||
|
'nick': 'urlbot'
|
||||||
|
}
|
||||||
|
|
||||||
def conf(val):
|
def conf(val):
|
||||||
if val in config.keys():
|
if val in config.keys():
|
||||||
|
|||||||
Reference in New Issue
Block a user