def get(self, livre, chapitre, verset, complexity): verse = str(Dbt.find_verse("DBY", str(livre), int(chapitre), int(verset))) str_verse = verse[1:-1] new_vers = complexify_verse(int(complexity), str_verse) print("new verse = ", new_vers) result = {"set_attributes": {"verse_txt": str_verse},"messages": [{"text": new_vers}]} return jsonify(result)
def get_chapter_verses(message, read_words, query): pattern_chapter = "(?P<book_number>\d)*(\s)*(?P<book_name>\w+)(\s)+(?P<chapter_number>\d)+" search_chapter = re.search(pattern_chapter, query) if search_chapter is not None: if search_chapter.group("book_number") is None: bk = search_chapter.group("book_name") else: bk = search_chapter.group("book_number") + search_chapter.group("book_name") verses = Dbt.find_chapter("DBY", bk, search_chapter.group("chapter_number")).get_verses() return verses else: return []
def get(self): # verse_final # complexified_verse = complexify_verse(complex, verse_final) # complexified_verse = complexify_verse(complexity, verse) # verse_txt_from_verse_ref() #write function that get verse ref # verse = str(Dbt.find_verse("DBY", "Jean", 3, 16)) verse = str(Dbt.find_verse("DBY", "Jean", 3,16)) str_verse = verse[1:-1] print("verse_ref_sent = ", str_verse) # new_vers = complexify_verse(int(complexity), str_verse) # print("new verse = ", new_vers) result = {"set_attributes": {"verse_txt": str_verse},"messages": [{"text": str_verse}]} return jsonify(result)
def get_verse(message, read_words): for rwrod in read_words: if rwrod in message: v = message.split(rwrod,1)[1] v = v.strip() pattern_verse = "(?P<book_number>\d)*(\s)*(?P<book_name>\w+)(\s)+(?P<chapter_number>\d)+(\s)*([-|verset|v|\.|,])+(\s)*(?P<verse_number>\d)+" search_verse = re.search(pattern_verse, v) if search_verse is not None: if search_verse.group("book_number") is None: bk = search_verse.group("book_name") else: bk = search_verse.group("book_number")+search_verse.group("book_name") verse = Dbt.find_verse("DBY", bk , search_verse.group("chapter_number"), search_verse.group("verse_number")) print('--------> '+verse.text) return [verse] else: print('------------> ') return get_chapter_verses(message, read_words, v)
async def on_message(message): # we do not want the bot to reply to itself if message.author == client.user: return if message.content.lower().startswith('bonjour'): msg = 'Bonjour {0.author.mention}'.format(message) await client.send_message(message.channel, msg) elif any(ext in message.content.lower() for ext in read_random_word): verse = Dbt.get_random_verse("DBY") await client.send_message( message.channel, "{} {} - verset {} : {}".format(verse.chapter.book.name, verse.chapter.chapter_number, verse.verse_number, verse.text)) elif any(ext in message.content.lower() for ext in read_verse_words): verses = get_verse(message.content.lower(), read_verse_words) # verses_complexified = verses.split() # list_index = random.sample(range(len(verses.split())), part) # for index in list_index: # length = len(verse_list[index]) # verse_list[index] = "_"*length # verse_final = ' '.join(verse_list) # print() # print(verses_complexified) # for verse in verses: # await client.send_message(message.channel, "{} {} - verset {} : {}".format(verse.chapter.book.name, verse.chapter.chapter_number, verse.verse_number, verse.text)) for i in range(3): time.sleep(10) for verse in verses: str_verse = str(verse)[1:-2] complex_verse = complexify_verse(3, str_verse) await client.send_message(message.channel, complex_verse)
def get(self): # r est la chaîne que l'API bible nous a renvoyé # verset_brut = remove_tags(htmlValue): # headers = {'api-key': '0fff648164b9a80b9b89b5ddce43c9e7',} # response = requests.get('https://api.scripture.api.bible/v1/bibles/2ef4ad5622cfd98b-01/'+, headers=headers) # utiliser le dbt de python versify de willy # resp = response.json() # htmlValue = resp['content'] def remove_tags(text):''.join(xml.etree.ElementTree.fromstring(text).itertext()) # resp = r.json() # htmlValue = resp['content'] # def remove_tags(text): ''.join(xml.etree.ElementTree.fromstring(text).itertext()) # verset_brut = remove_tags(htmlValue): # print(dbt.find_verse("DBY", "1 Timothée", 2, 1)) # txt = verse_sent # txt = "Hello world c'est MemoVerset sur Chatfuel" verse = str(Dbt.find_verse("DBY", "Jean", 3, 16)) str_verse = verse[1:-1] new_vers = complexify_verse(2, str_verse) # print(new_vers) result = {"messages": [{"text": new_vers},]} return jsonify(result)