forked from metalfiiish/ts-gw2-verifyBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot_messages.py
162 lines (122 loc) · 10.7 KB
/
bot_messages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#######################################
## BOT Messages
#######################################
import TS3Auth
import re
import Logger
log = Logger.getLogger()
class Locale(object):
def __init__(self, fallback = None):
self._fallback = fallback
self._values = {}
def get(self, key, args = ()):
'''
key: the string to identify the locale-string with
args: an optional tuple of arguments to pass to the old style formatter. If the number of arguments don't match the number of template spots in the string, no argument will be inserted at all
returns: either the looked-up locale-string, the loooked-up locale from the fallback Locale (if any) or the key as fallback-fallback
'''
tpl = ""
if key in self._values:
tpl = self._values[key]
elif self._fallback is not None:
tpl = self._fallback.get(key)
else:
tpl = key
try:
tpl = tpl % args
except TypeError:
log.error("Could not insert all %d arguments into the string with key '%s' of locale %s. I will not insert any arguments at all.", len(args), key, self.__class__.__name__)
return tpl
def set(self, key, value):
self._values[key] = value
class Multi(Locale):
def __init__(self, locales, glue = "\n\n-------------------------------------\n\n"):
super(Multi, self).__init__()
self._locales = locales
self._glue = glue
def get(self, key, args = ()):
return self._glue.join([l.get(key, args) for l in self._locales])
class English(Locale):
def __init__(self):
super(English, self).__init__()
self.set("bot_msg_example", "\n\nExample:\n\t\t7895D172-4991-9546-CB5B-78B015B0D8A72BC0E007-4FAF-48C3-9BF1-DA1OAD241266")
self.set("bot_msg_note", "\n\nNOTE: Guild Wars 2 API keys can be created/deleted via ArenaNet site [URL]account.arena.net/applications[/URL].")
self.set("bot_msg_verify", "Hello there! I believe you requested verification?\n\nIf so please reply back to THIS PRIVATE MESSAGE with your API key. Please make sure the key has the permissions [b]account[/b] and [b]characters[/b]."+self.get("bot_msg_example")+self.get("bot_msg_note"))
# Banner that we send to all users upon initialization
self.set("bot_msg", "%s is alive once again! If you require verification, please reconnect!")
# Broadcast message
self.set("bot_msg_broadcast", "Hello there! You can begin verification by typing 'verifyme' in this channel.")
#Message sent for sucesful verification
self.set("bot_msg_success", "Authentication was succesful! Thank you fellow adventurer. Please give our rules a read and have fun \(^.^)/ If you don't see any people, please relog once.")
#Message sent for failed verification
self.set("bot_msg_fail", "Unfortuntely your authentication failed. Ask the Teamspeak admin to review the logs.\n~ Likely a bad API key or incorrect API settings. (API Key needs access to 'account' and 'character' )"+self.get("bot_msg_note"))
#Message sent for client TS ID limit reached (trying to access Teamspeack from a second computer after having authenticated on a prior machine
self.set("bot_msg_limit_Hit", "The TeamSpeak Admins have set a limit to how many computers can authenticate with your Guild Wars 2 account. You are already authenticated from a different computer (or you reinstalled Teamspeak client which reset your TeamSpeak ID with this server).")
#Message sent to someone who is already verified but asks to be verified
self.set("bot_msg_alrdy_verified", "It looks like you are already verified! Why do you torture me sooo /cry")
#Message sent to someone who is not verified but asks to set guild tags via channel text.
self.set("bot_msg_sguild_nv", "I'm sorry, I can't help you set guild tags unless you are authenticated. Please verify first by replying to me with your API key."+self.get("bot_msg_example")+self.get("bot_msg_note"))
#Message sent to someone who is verified and asks to set guild tags.
self.set("bot_msg_sguild", "Let's get to work! First, I need your API key. Reply back with your API key:"+self.get("bot_msg_example")+self.get("bot_msg_note"))
#Message sent to someone who is not verified and asks to set guild tags via private message.
self.set("bot_msg_gld_needs_auth", "Where you trying to change your guild tags? If so, please be aware you have not been verified yet! Read below to verify."+self.get("bot_msg_example"))
#Base Message sent to someone who gave us the API key to pull guild tags.
self.set("bot_msg_gld_lis", "API Authentication succeeded. Session built. Here are your guild TAGS your can choose to assign:")
#Default message we send to Private messages that didn't match a command
self.set("bot_msg_rcv_default", "Hrm...So I get that your saying something but I don't understand what. Are you trying to get verified? If so please provide your API key in the format:"+self.get("bot_msg_example")+self.get("bot_msg_note"))
# User successfully hid a guild
self.set("bot_hide_guild_success", "Okay, I will not give you this tag again upon revalidation. You can [b]unhide[/b] the tag at any time.")
# User passed an invalid guild
self.set("bot_hide_guild_unknown", "Sorry, there seems to be no such guild or you have already hidden it. Please make sure you use the exact spelling that is used for the TS group.")
# User successfully hid a guild
self.set("bot_unhide_guild_success", "Okay, you will receive this group with the next revalidation, if you are entitled to get it.")
# User passed an invalid guild
self.set("bot_unhide_guild_unknown", "Sorry, there seems to be no such guild-group or you have not hidden it. Please make sure you use the exact spelling that is used for the TS group.")
class German(Locale):
def __init__(self):
super(German, self).__init__(English())
self.set("bot_msg_example", "\n\nBeispiel:\n\t\t7895D172-4991-9546-CB5B-78B015B0D8A72BC0E007-4FAF-48C3-9BF1-DA1OAD241266")
self.set("bot_msg_note", "\n\nINFO: Guild Wars 2 API keys können über die ArenaNet-Seite [URL]account.arena.net/applications[/URL] erstellt/gelöscht werden.")
self.set("bot_msg_verify", "Hallöchen! Möchtest du dich registrieren?\n\nFalls ja, antworte bitte per PRIVATER NACHRICHT mit deinem API-Key. Bitte achte darauf, dass der Key die Berechtigungen [b]account[/b] und [b]characters[/b] besitzt."+self.get("bot_msg_example")+self.get("bot_msg_note"))
# Banner that we send to all users upon initialization
self.set("bot_msg", "%s ist wieder da! Falls du eine Freischaltung benötigst, verbinde dich bitte neu!")
# Broadcast message
self.set("bot_msg_broadcast", "Hallöchen! Du kannst die Freischaltung beginnen, indem du 'verifyme' in diesem Channel schreibst.")
#Message sent for sucesful verification
self.set("bot_msg_success", "Freischaltung erfolgreich! Danke dir, Abenteurer. Bitte lies dir unsere Regeln durch und dann viel Spaß \(^.^)/ Falls du keine User sehen kannst, relogge dich bitte einmal.")
#Message sent for failed verification
self.set("bot_msg_fail", "Leider hat die Freischaltung nicht funktioniert. Bitte einen Teamspeak Administrator die Logs zu prüfen.\n~ Wahrscheinlich ein ungültiger API-Schlüssel oder falsche API-Einstellungen. (Der API-Schlüssel braucht die Berechtigungen 'account' und 'character' )"+self.get("bot_msg_note"))
#Message sent for client TS ID limit reached (trying to access Teamspeack from a second computer after having authenticated on a prior machine
self.set("bot_msg_limit_Hit", "Die Teamspeak Admins haben ein Limit gesetzt, auf wie vielen Geräten du dich mit deinem Guild Wars 2 Account freischalten kannst. Du bist bereits von einem anderen Gerät aus registriert (oder du hat Teamspeak neu installiert, wodurch deine Teamspeak ID für diesen Server zurückgesetzt wurde).")
#Message sent to someone who is already verified but asks to be verified
self.set("bot_msg_alrdy_verified", "Es scheint, als seist du bereits freigeschaltet! Wieso quälst du mich sooo /cry")
#Message sent to someone who is not verified but asks to set guild tags via channel text.
self.set("bot_msg_sguild_nv", "Tut mir leid, ich kann dir erst dabei helfen, ein Gildentag zu setzen, sobald du freigeschaltet bist. Bitte schalte dich frei, indem du mir mit einem API-Schlüssel antwortest."+self.get("bot_msg_example")+self.get("bot_msg_note"))
#Message sent to someone who is verified and asks to set guild tags.
self.set("bot_msg_sguild", "Lass uns anfangen! Zuerst brauche ich deinen API-Schlüssel. Antworte mir mit deinem API-Schlüssel:"+self.get("bot_msg_example")+self.get("bot_msg_note"))
#Message sent to someone who is not verified and asks to set guild tags via private message.
self.set("bot_msg_gld_needs_auth", "Wolltest du dein Gildentag ändern? Falls ja, beachte, dass du noch nicht freigeschaltet bist! Lies weiter, um dich freizuschalten."+self.get("bot_msg_example"))
#Base Message sent to someone who gave us the API key to pull guild tags.
self.set("bot_msg_gld_lis", "API-Freischaltung erfolgreich. Sitzung erstellt. Hier sind die Gildentags, aus denen du wählen kannst:")
#Default message we send to Private messages that didn't match a command
self.set("bot_msg_rcv_default", "Hm... ich merke, dass du etwas von mir willst, aber ich verstehe dich nicht. Möchtest du dich freischalten? Falls ja, bitte gib deinen API-Schlüssel in folgendem Format an:"+self.get("bot_msg_example")+self.get("bot_msg_note"))
# User successfully hid a guild
self.set("bot_hide_guild_success", "Okay, ich werde dir diese Gruppe bei der Revalidierung nichtmehr geben. Du kannst die Gruppe jederzeit wieder [b]unhide[/b]n.")
# User passed an invalid guild
self.set("bot_hide_guild_unknown", "Tut mir Leid, eine solche Gilde scheint es nicht zu geben oder du hast sie bereits versteckt. Bitte stelle sicher, dass du die exakte Schreibweise der Gildengruppe hier im Teamspeak verwendest.")
# User successfully hid a guild
self.set("bot_unhide_guild_success", "Okay, du wirst die Gruppe bei der nächsten Revalidierung wieder erhalten, wenn du dazu berechtigt bist.")
# User passed an invalid guild
self.set("bot_unhide_guild_unknown", "Tut mir Leid, eine solche Gilde scheint es nicht zu geben or du hattest die Gruppe nicht versteckt. Bitte stelle sicher, dass du die exakte Schreibweise der Gildengruppe hier im Teamspeak verwendest.")
def getLocale(locale):
locale = locale or "" # make sure upper() doesn't fail on empty arguments
locale = locale.upper()
locales = locale.split("+")
if len(locales) > 1:
return Multi([getLocale(l) for l in locales])
elif locale == "DE":
return German()
elif locale == "EN":
return English()
else:
return English() # catchall