from __future__ import absolute_import
import logging

from .telegram import TelegramBot


logger = logging.getLogger(__name__)


class TelegramBotSplit(TelegramBot):
    def __init__(self, chat_id=None, split_on="\n"):
        self.split_on = split_on
        super(TelegramBotSplit, self).__init__(chat_id=chat_id)

    def post(self, report, **kwargs):
        """Overwrite post to split message on token"""
        for m in report.split(self.split_on):
            self.bot.send_message(
                self.chat_id,
                m,
                parse_mode='Markdown',
            )


def notify_factory(conf, value):
    try:
        chat_id = value['chat-id']
    except (TypeError, KeyError):
        chat_id = value
    try:
        split_on = value['split-on']
    except (TypeError, KeyError):
        split_on = "\n"

    print(split_on)
    return TelegramBotSplit(chat_id=chat_id, split_on=split_on).post


def chat_id():
    bot = TelegramBotSplit()
    print(bot.chat_id)

from __future__ import absolute_import
import logging

from .telegram import TelegramBot


logger = logging.getLogger(__name__)


class TelegramBotSplit(TelegramBot):
    def __init__(self, chat_id=None, split_on="\n"):
        self.split_on = split_on
        super(TelegramBotSplit, self).__init__(chat_id=chat_id)

    def post(self, report, **kwargs):
        """Overwrite post to split message on token"""
        for m in report.split(self.split_on):
            super(TelegramBotSplit, self).post(m)


def notify_factory(conf, value):
    try:
        chat_id = value['chat-id']
    except (TypeError, KeyError):
        chat_id = value
    try:
        split_on = value['split-on']
    except (TypeError, KeyError):
        split_on = "\n"

    return TelegramBotSplit(chat_id=chat_id, split_on=split_on).post


def chat_id():
    bot = TelegramBotSplit()
    print(bot.chat_id)

Use parent 'post' function to actually send message
Use parent 'post' function to actually send message

  from __future__ import absolute_import
  import logging
  
  from .telegram import TelegramBot
  
  
  logger = logging.getLogger(__name__)
  
  
  class TelegramBotSplit(TelegramBot):
      def __init__(self, chat_id=None, split_on="\n"):
          self.split_on = split_on
          super(TelegramBotSplit, self).__init__(chat_id=chat_id)
  
      def post(self, report, **kwargs):
          """Overwrite post to split message on token"""
          for m in report.split(self.split_on):
+             super(TelegramBotSplit, self).post(m)
-             self.bot.send_message(
-                 self.chat_id,
-                 m,
-                 parse_mode='Markdown',
-             )
  
  
  def notify_factory(conf, value):
      try:
          chat_id = value['chat-id']
      except (TypeError, KeyError):
          chat_id = value
      try:
          split_on = value['split-on']
      except (TypeError, KeyError):
          split_on = "\n"
  
-     print(split_on)
      return TelegramBotSplit(chat_id=chat_id, split_on=split_on).post
  
  
  def chat_id():
      bot = TelegramBotSplit()
      print(bot.chat_id)
  
Use parent 'post' function to actually send message
## Code Before:
from __future__ import absolute_import
import logging

from .telegram import TelegramBot


logger = logging.getLogger(__name__)


class TelegramBotSplit(TelegramBot):
    def __init__(self, chat_id=None, split_on="\n"):
        self.split_on = split_on
        super(TelegramBotSplit, self).__init__(chat_id=chat_id)

    def post(self, report, **kwargs):
        """Overwrite post to split message on token"""
        for m in report.split(self.split_on):
            self.bot.send_message(
                self.chat_id,
                m,
                parse_mode='Markdown',
            )


def notify_factory(conf, value):
    try:
        chat_id = value['chat-id']
    except (TypeError, KeyError):
        chat_id = value
    try:
        split_on = value['split-on']
    except (TypeError, KeyError):
        split_on = "\n"

    print(split_on)
    return TelegramBotSplit(chat_id=chat_id, split_on=split_on).post


def chat_id():
    bot = TelegramBotSplit()
    print(bot.chat_id)

## Instruction:
Use parent 'post' function to actually send message
## Code After:
from __future__ import absolute_import
import logging

from .telegram import TelegramBot


logger = logging.getLogger(__name__)


class TelegramBotSplit(TelegramBot):
    def __init__(self, chat_id=None, split_on="\n"):
        self.split_on = split_on
        super(TelegramBotSplit, self).__init__(chat_id=chat_id)

    def post(self, report, **kwargs):
        """Overwrite post to split message on token"""
        for m in report.split(self.split_on):
            super(TelegramBotSplit, self).post(m)


def notify_factory(conf, value):
    try:
        chat_id = value['chat-id']
    except (TypeError, KeyError):
        chat_id = value
    try:
        split_on = value['split-on']
    except (TypeError, KeyError):
        split_on = "\n"

    return TelegramBotSplit(chat_id=chat_id, split_on=split_on).post


def chat_id():
    bot = TelegramBotSplit()
    print(bot.chat_id)
