# Path: stampy/i18n.py
# def _(string):
#     """
#     Provides translation of string based on current language
#     :param string: String to translate
#     :return: Translated string
#     """
#     language = stampy.language
# 
#     localedir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'locale')
#     trad = gettext.translation('stampy', localedir, fallback=True, languages=[language])
#     return trad.ugettext(string)
# 
# Path: stampy/i18n.py
# def _L(string):
#     """
#     Provides translation of string based on current language
#     :param string: String to translate
#     :return: Translated string
#     """
#     loglanguage = stampy.loglanguage
# 
#     localedir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'locale')
#     trad = gettext.translation('stampy', localedir, fallback=True, languages=[loglanguage])
#     return trad.ugettext(string)


import json
import logging
import requests
import stampy.plugin.config
import stampy.stampy
from time import sleep
from prettytable import from_db_cursor
from stampy.i18n import _
from stampy.i18n import _L
    :param target: Target chat_id
    :return:
    """

    logger = logging.getLogger(__name__)

    msgdetail = stampy.stampy.getmsgdetail(message)
    chat_id = msgdetail["chat_id"]
    message_id = msgdetail["message_id"]

    url = "%s%s/forwardMessage" % (stampy.plugin.config.config(key="url"),
                                   stampy.plugin.config.config(key='token'))

    forwardmessageurl = "%s?chat_id=%s&from_chat_id=%s&message_id=%s" % (url, target, chat_id, message_id)

    code = False
    attempt = 0
    exitcode = 0

    while not code:
        # It this is executed as per unit testing, skip sending message
        UTdisable = not stampy.plugin.config.config(key='unittest', default=False)
        if UTdisable:
            output = json.loads(requests.get(forwardmessageurl).text)
            result = {"message": output['result']}
            code = output['ok']
        else:
            code = True
            result = ""


# Path: stampy/i18n.py
# def _(string):
#     """
#     Provides translation of string based on current language
#     :param string: String to translate
#     :return: Translated string
#     """
#     language = stampy.language
# 
#     localedir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'locale')
#     trad = gettext.translation('stampy', localedir, fallback=True, languages=[language])
#     return trad.ugettext(string)
# 
# Path: stampy/i18n.py
# def _L(string):
#     """
#     Provides translation of string based on current language
#     :param string: String to translate
#     :return: Translated string
#     """
#     loglanguage = stampy.loglanguage
# 
#     localedir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'locale')
#     trad = gettext.translation('stampy', localedir, fallback=True, languages=[loglanguage])
#     return trad.ugettext(string)


# Path: stampy/plugin/forward.py
import json
import logging
import requests
import stampy.plugin.config
import stampy.stampy
from time import sleep
from prettytable import from_db_cursor
from stampy.i18n import _
from stampy.i18n import _L

    :param target: Target chat_id
    :return:
    """

    logger = logging.getLogger(__name__)

    msgdetail = stampy.stampy.getmsgdetail(message)
    chat_id = msgdetail["chat_id"]
    message_id = msgdetail["message_id"]

    url = "%s%s/forwardMessage" % (stampy.plugin.config.config(key="url"),
                                   stampy.plugin.config.config(key='token'))

    forwardmessageurl = "%s?chat_id=%s&from_chat_id=%s&message_id=%s" % (url, target, chat_id, message_id)

    code = False
    attempt = 0
    exitcode = 0

    while not code:
        # It this is executed as per unit testing, skip sending message
        UTdisable = not stampy.plugin.config.config(key='unittest', default=False)
        if UTdisable:
            output = json.loads(requests.get(forwardmessageurl).text)
            result = {"message": output['result']}
            code = output['ok']
        else:
            code = True
            result = ""


        logger.error(msg=_L("ERROR (%s) forwarding message: Code: %s : Text: %s") % (attempt, code, result))