def handle(self,text): if self.msg.connection.contact == None: if en_or_ka(self.en_keyword,self.msg.text) == "en": return self.respond_error("You aren't signed up!") else: return self.respond_error("daregistrirebuli ar xart!") else: contact = self.msg.connection.contact cats = Category.objects.all() matched_cats = [] keywords = text.split(' ') # remove punctuation dot as last char if keywords[-1][-1] == '.': keywords[-1] = keywords[-1][:-1] for key in keywords: if key.upper() == 'ALL' or key.upper() == 'YVELA' or key.upper() == 'YVELAS': self.respond(_("You have been removed from our lists.")) self.msg.connection.contact.delete() return #compare key to Category match strings. for cat in cats: # If match, add to category ids, remove from queryset if cat.matchesKeyword(key): matched_cats.append(cat) cats = cats.exclude(id=cat.id) if len(matched_cats) == 0: cats = Category.objects.all().order_by('?')[:2] examples = "" if en_or_ka(self.en_keyword,self.msg.text) == "en": # Georgian keywords must always be last. # Sorry, that sucks, I know. index = 0 else: index = -1 for c in cats: examples = examples + " " + c.keyword_array()[index] return self.respond_error(_("We couldn't find any of the committees you entered. Here are some possibilities:")+examples) old_len = contact.categories.all().count() contact.categories.remove(*matched_cats) if contact.categories.all().count() == 0: self.respond(_("You have been removed from our lists.")) self.msg.connection.contact.delete() return else: self.respond(_("Successfully removed subscriptions: ")+str(old_len-contact.categories.all().count())) contact.save()
def help(self): if self.msg.connection.contact == None: if en_or_ka(self.en_keyword,self.msg.text) == "en": return self.respond_error("You aren't signed up!") else: return self.respond_error("daregistrirebuli ar xart!") self.respond(_("To set your language, send LANGUAGE CODE. Send LANGUAGE KA for Georgian, LANGUAGE EN for English."))
def help(self): if self.msg.connection.contact == None: if en_or_ka(self.en_keyword,self.msg.text) == "en": return self.respond_error("You aren't signed up!") else: return self.respond_error("daregistrirebuli ar xart!") self.respond(_("To delete your subscription, send LEAVE COMMITTEE, for example LEAVE ECONOMY, or LEAVE ALL."))
def handle(self, text): if self.msg.connection.contact == None: # Generate contact if first signup contact = Contact.objects.create(name=str(self.msg.connection.identity)) contact.language = en_or_ka(self.en_keyword,self.msg.text) self.msg.connection.contact = contact self.msg.connection.save() contact = self.msg.connection.contact cats = Category.objects.all() matched_cats = [] keywords = text.split(' ') # remove punctuation dot as last char if keywords[-1][-1] == '.': keywords[-1] = keywords[-1][:-1] for key in keywords: if key.upper() == 'ALL' or key.upper() == 'YVELAS' or key.upper() == 'YVELA': matched_cats = list(Category.objects.all()) break #compare key to Category match strings. for cat in cats: # Probably should have implemented keywords as OneToOne field. Oops. # If match, add to category ids, remove from queryset if cat.matchesKeyword(key): matched_cats.append(cat) cats = cats.exclude(id=cat.id) for c in matched_cats: # Don't allow signup for debug. if c.matchesKeyword("DEBUG"): matched_cats.remove(c) break if len(matched_cats) == 0: cats = Category.objects.all().order_by('?')[:2] examples = "" if contact.language == "en": # For this reason, Georgian keywords must always be last. # Sorry, that sucks, I know. index = 0 else: index = -1 for c in cats: examples = examples + " " + c.keyword_array()[index] return self.respond_error(_("We couldn't find any of the committees you entered. Here are some examples to get you started:")+examples) contact.categories.add(*matched_cats) contact.save() self.respond(_("Thank you for registering! To stop receiving updates, send LEAVE COMMITTEE, for example LEAVE ECONOMY or LEAVE ALL."))
def handle(self, text): if en_or_ka(self.en_keyword, text) == 'en': return self.respond('You are welcome!') else: return self.respond('arafris!')
def help(self): if en_or_ka(self.en_keyword,self.msg.text) == "en": self.respond("To sign up, send JOIN <COMMITTEE>, e.g. JOIN ECONOMY. To subscribe to all committees, send JOIN ALL.") else: self.respond("imistvis rom daregistrirdet, gaagzavnet GAMOICERE KOMITETI, magalitad GAMOICERE EKONOMIKA. imisatvis rom sheurtde yvela komitets, gaagzavne GAMOICERE YVELA")