mirror of
https://github.com/mightyBroccoli/xmpp-chatbot.git
synced 2024-11-09 20:41:25 +01:00
code quality improvements
- remove unused variable * better iteration of xdata nodes - removed unnecessary else
This commit is contained in:
parent
d1b8090ee8
commit
cd1442e216
4 changed files with 7 additions and 14 deletions
|
@ -34,11 +34,11 @@ class ServerContact:
|
||||||
# extract jabber:x:data from query
|
# extract jabber:x:data from query
|
||||||
xdata = query.findall('{jabber:x:data}x')
|
xdata = query.findall('{jabber:x:data}x')
|
||||||
|
|
||||||
# check for multiple x nodes
|
# iterate over all nodes with the xdata tag
|
||||||
for x in range(len(xdata)):
|
for node in xdata:
|
||||||
|
|
||||||
# iterate over all x nodes
|
# iterate over all child elements in node
|
||||||
for child in xdata[x]:
|
for child in node:
|
||||||
|
|
||||||
# if one opt_arg is defined return just that one
|
# if one opt_arg is defined return just that one
|
||||||
if self.opt_arg in self.possible_vars:
|
if self.opt_arg in self.possible_vars:
|
||||||
|
|
|
@ -46,8 +46,7 @@ def validate(keyword, target):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# if the target could not be validated until this return False
|
# if the target could not be validated until this return False
|
||||||
else:
|
return False
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -33,9 +33,9 @@ class StaticAnswers:
|
||||||
# if specific keyword in referenced return that
|
# if specific keyword in referenced return that
|
||||||
if key in self.keywords.keys():
|
if key in self.keywords.keys():
|
||||||
return self.keywords[key]
|
return self.keywords[key]
|
||||||
|
|
||||||
# in any other case return the whole dict
|
# in any other case return the whole dict
|
||||||
else:
|
return self.keywords["keywords"]
|
||||||
return self.keywords["keywords"]
|
|
||||||
|
|
||||||
def gen_help(self):
|
def gen_help(self):
|
||||||
helpdoc = "\n".join(['%s' % value for (_, value) in self.helpfile.items()])
|
helpdoc = "\n".join(['%s' % value for (_, value) in self.helpfile.items()])
|
||||||
|
|
6
main.py
6
main.py
|
@ -38,12 +38,6 @@ class QueryBot(slixmpp.ClientXMPP):
|
||||||
"!xep": XEPRequest()
|
"!xep": XEPRequest()
|
||||||
}
|
}
|
||||||
|
|
||||||
self.data = {
|
|
||||||
'words': list(),
|
|
||||||
'reply': list(),
|
|
||||||
'queue': list()
|
|
||||||
}
|
|
||||||
|
|
||||||
# session start event, starting point for the presence and roster requests
|
# session start event, starting point for the presence and roster requests
|
||||||
self.add_event_handler('session_start', self.start)
|
self.add_event_handler('session_start', self.start)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue