summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rwxr-xr-xcommon/misc.py30
-rw-r--r--common/strings.py6
2 files changed, 16 insertions, 20 deletions
diff --git a/common/misc.py b/common/misc.py
index abcc05e..86798b8 100755
--- a/common/misc.py
+++ b/common/misc.py
@@ -24,26 +24,20 @@ def validate(keyword, target):
:param target: provided target
:return: true if valid
"""
- # check if keyword is in the argument list
- if keyword in StaticAnswers().keys():
-
- # if keyword in domain_keywords list
- if keyword in StaticAnswers().keys('domain_keywords'):
- # if target is a domain / email return True
- if validators.domain(target):
- return True
- elif validators.email(target):
- return True
+ # if keyword in domain_keywords list
+ if keyword in StaticAnswers().keys('domain_keywords'):
+ # if target is a domain / email return True
+ if validators.domain(target) or validators.email(target):
+ return True
- # check if keyword is in number_keyword list
- elif keyword in StaticAnswers().keys('number_keywords'):
- # if target only consists of digits return True
- if target.isdigit():
- return True
+ # check if keyword is in number_keyword list
+ elif keyword in StaticAnswers().keys('number_keywords'):
+ # if target only consists of digits return True
+ return target.isdigit()
- # if keyword is in no_arg_keywords list return True
- elif keyword in StaticAnswers().keys("no_arg_keywords"):
- return True
+ # if keyword is in no_arg_keywords list return True
+ elif keyword in StaticAnswers().keys("no_arg_keywords"):
+ return True
# if the target could not be validated until this return False
return False
diff --git a/common/strings.py b/common/strings.py
index 7a10471..6f1b629 100644
--- a/common/strings.py
+++ b/common/strings.py
@@ -13,11 +13,13 @@ class StaticAnswers:
'version': '!version domain.tld -- receive XMPP server version',
'uptime': '!uptime domain.tld -- receive XMPP server uptime',
'contact': '!contact domain.tld -- receive XMPP server contact address info',
- 'xep': '!xep XEP Number -- recieve information about the specified XEP'}
+ 'xep': '!xep XEP Number -- recieve information about the specified XEP'
+ }
self.possible_answers = {
'1': 'I heard that, %s.',
'2': 'I am sorry for that %s.',
- '3': '%s did you try turning it off and on again?'}
+ '3': '%s did you try turning it off and on again?'
+ }
self.error_messages = {
'1': 'not reachable',
'2': 'not a valid target'