summaryrefslogtreecommitdiffstats
path: root/classes/strings.py
diff options
context:
space:
mode:
authornico <nico.wellpott@uni-oldenburg.de>2018-11-11 03:43:27 +0100
committerGitHub <noreply@github.com>2018-11-11 03:43:27 +0100
commitce1af725d7d01d68130a94e8b779b7674bedb5d1 (patch)
tree3798538b14cc67e7deed4adc44957b4cc4607019 /classes/strings.py
parentc6a549669acb2dbac083e5cdca575add3968174d (diff)
parent1b13bdfd926e394cab2a2edd15ecabf0afcc4cf2 (diff)
Merge pull request #7 from mightyBroccoli/dev
# added + added more comments to xep requests + added opt_arg to version, xep and contact + implemented data dictionary to hold all data in main bot + added message_ids # changed * updated gitignore file * partly reworked servercontact implementation * complete rework of uptime, version * part rework of xep requests * complete rework of validate function * updated HandleError function * part rework of StaticStrings function * complete rework of queue building and deduplication
Diffstat (limited to 'classes/strings.py')
-rw-r--r--classes/strings.py54
1 files changed, 0 insertions, 54 deletions
diff --git a/classes/strings.py b/classes/strings.py
deleted file mode 100644
index 6866a31..0000000
--- a/classes/strings.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# -*- coding: utf-8 -*-
-from random import randint
-
-
-class StaticAnswers:
- """
- collection of callable static/ semi-static strings
- """
- def __init__(self, nick=""):
- self.nickname = nick
- self.helpfile = {
- 'help': '!help -- display this text',
- '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'}
- 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?'}
- self.error_messages = {
- '1': 'not reachable',
- '2': 'not a valid target'
- }
- self.keywords = {
- "keywords": ["!help", "!uptime", "!version", "!contact", "!xep"],
- "domain_keywords": ["!uptime", "!version", "!contact"],
- "no_arg_keywords": ["!help"],
- "number_keywords": ["!xep"]
- }
-
- def keys(self, arg="", keyword='keywords'):
- if arg == 'list':
- try:
- return self.keywords[keyword]
- except KeyError:
- return self.keywords['keywords']
- else:
- return self.keywords
-
- def gen_help(self):
- helpdoc = "\n".join(['%s' % value for (_, value) in self.helpfile.items()])
- return helpdoc
-
- def gen_answer(self):
- possible_answers = self.possible_answers
- return possible_answers[str(randint(1, possible_answers.__len__()))] % self.nickname
-
- def error(self,code):
- try:
- text = self.error_messages[str(code)]
- except KeyError:
- return 'unknown error'
- return text