Exemple #1
0
class ODOATest(unittest.TestCase):

    def setUp(self):
        self.odoa = ODOA()

    def test_get_surah(self):
        surah = self.odoa.get_random_surah()
        self.assertIsNotNone(surah)
        surah = self.odoa.get_random_surah(lang='en')
        self.assertIsNotNone(surah)

    def test_not_supported_language(self):
        with self.assertRaises(ODOAException):
            self.odoa.get_random_surah('fr')
async def main():
    o = ODOA()

    surah = await o.get_random_surah()

    print(surah.ayah)
    print(surah.desc)
    print(surah.translate)
    print(surah.sound)
Exemple #3
0
 def setUp(self):
     self.odoa = ODOA()
Exemple #4
0
import logging
import os

from dotenv import load_dotenv, find_dotenv
from odoa import ODOA
from telegram.ext import Updater, CommandHandler

from dbutils import DBUtils

odoa = ODOA()
load_dotenv(find_dotenv())
logging.basicConfig(
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    level=logging.INFO,
)
logger = logging.getLogger(__name__)
db = DBUtils(db_name=os.getenv('DB'))


def get_surah():
    surah = odoa.get_random_surah()
    ayah = surah.ayah.decode('utf8')
    description = surah.desc
    translate = surah.translate
    message = f'{description}\n\n{ayah}\n\n{translate}'
    return message


def start_handler(bot, update):
    username = update.message.from_user.username
    message = (f'Hi {username},\n\n'