
import sys

import instabot

NICKNAME = 'Echo'

def post_cb(self, msg, meta):
    if msg['text'].startswith('!echo '):
        return msg['text'][6:]

def main():
    b = instabot.CmdlineBotBuilder(defnick=NICKNAME)
    b.make_parser(sys.argv[0],
                  desc='An Instant bot bouncing back received messages.')
    b.parse(sys.argv[1:])
    bot = b(post_cb=post_cb)
    try:
        bot.run()
    except KeyboardInterrupt:
        sys.stderr.write('\n')
    finally:
        bot.close()

if __name__ == '__main__': main()


import sys

import instabot

NICKNAME = 'Echo'

def post_cb(self, msg, meta):
    if msg['text'].startswith('!echo '):
        return msg['text'][6:]

def main():
    b = instabot.CmdlineBotBuilder(defnick=NICKNAME)
    b.make_parser(sys.argv[0],
                  desc='An Instant bot bouncing back received messages.')
    b.parse(sys.argv[1:])
    bot = b(keepalive=True, post_cb=post_cb)
    try:
        bot.run()
    except KeyboardInterrupt:
        sys.stderr.write('\n')
    finally:
        bot.close()

if __name__ == '__main__': main()

Make example bot use keepalive
[Instabot] Make example bot use keepalive

  
  import sys
  
  import instabot
  
  NICKNAME = 'Echo'
  
  def post_cb(self, msg, meta):
      if msg['text'].startswith('!echo '):
          return msg['text'][6:]
  
  def main():
      b = instabot.CmdlineBotBuilder(defnick=NICKNAME)
      b.make_parser(sys.argv[0],
                    desc='An Instant bot bouncing back received messages.')
      b.parse(sys.argv[1:])
-     bot = b(post_cb=post_cb)
+     bot = b(keepalive=True, post_cb=post_cb)
      try:
          bot.run()
      except KeyboardInterrupt:
          sys.stderr.write('\n')
      finally:
          bot.close()
  
  if __name__ == '__main__': main()
  
Make example bot use keepalive
## Code Before:

import sys

import instabot

NICKNAME = 'Echo'

def post_cb(self, msg, meta):
    if msg['text'].startswith('!echo '):
        return msg['text'][6:]

def main():
    b = instabot.CmdlineBotBuilder(defnick=NICKNAME)
    b.make_parser(sys.argv[0],
                  desc='An Instant bot bouncing back received messages.')
    b.parse(sys.argv[1:])
    bot = b(post_cb=post_cb)
    try:
        bot.run()
    except KeyboardInterrupt:
        sys.stderr.write('\n')
    finally:
        bot.close()

if __name__ == '__main__': main()

## Instruction:
Make example bot use keepalive
## Code After:

import sys

import instabot

NICKNAME = 'Echo'

def post_cb(self, msg, meta):
    if msg['text'].startswith('!echo '):
        return msg['text'][6:]

def main():
    b = instabot.CmdlineBotBuilder(defnick=NICKNAME)
    b.make_parser(sys.argv[0],
                  desc='An Instant bot bouncing back received messages.')
    b.parse(sys.argv[1:])
    bot = b(keepalive=True, post_cb=post_cb)
    try:
        bot.run()
    except KeyboardInterrupt:
        sys.stderr.write('\n')
    finally:
        bot.close()

if __name__ == '__main__': main()
