Example #1
0
def main():
    """Parse the command-line arguments and run the bot."""
    parser = argparse.ArgumentParser(description='XMPP echo bot',
                                     parents=[XMPPSettings.get_arg_parser()])
    parser.add_argument('jid', metavar='JID', help='The bot JID')

    parser.add_argument('tunnel_conf', metavar='TUNNEL_CONF')

    parser.add_argument('--debug',
                        action='store_const',
                        dest='log_level',
                        const=logging.DEBUG,
                        default=logging.INFO,
                        help='Print debug messages')
    parser.add_argument('--quiet',
                        const=logging.ERROR,
                        action='store_const',
                        dest='log_level',
                        help='Print only error messages')
    parser.add_argument('--trace',
                        action='store_true',
                        help='Print XML data sent and received')

    args = parser.parse_args()
    settings = XMPPSettings({"software_name": "TCP Tunneler Bot"})
    settings.load_arguments(args)

    if settings.get("password") is None:
        password = getpass("{0!r} password: "******"utf-8")
        settings["password"] = password

    if sys.version_info.major < 3:
        args.jid = args.jid.decode("utf-8")

    logging.basicConfig(level=args.log_level)
    if args.trace:
        print "enabling trace"
        handler = logging.StreamHandler()
        handler.setLevel(logging.DEBUG)
        for logger in ("pyxmpp2.IN", "pyxmpp2.OUT"):
            logger = logging.getLogger(logger)
            logger.setLevel(logging.DEBUG)
            logger.addHandler(handler)
            logger.propagate = False

    im_tcp_tunneler.setup_tunnels(args.tunnel_conf)

    global bot
    bot = Bot(JID(args.jid), settings)
    try:
        bot.run()
    except KeyboardInterrupt:
        bot.disconnect()
def main():
    """Parse the command-line arguments and run the bot."""
    parser = argparse.ArgumentParser(description = 'XMPP echo bot',
                                    parents = [XMPPSettings.get_arg_parser()])
    parser.add_argument('jid', metavar = 'JID', 
                        help = 'The bot JID')
    
    parser.add_argument('tunnel_conf', metavar = 'TUNNEL_CONF')
    
    parser.add_argument('--debug',
                        action = 'store_const', dest = 'log_level',
                        const = logging.DEBUG, default = logging.INFO,
                        help = 'Print debug messages')
    parser.add_argument('--quiet', const = logging.ERROR,
                        action = 'store_const', dest = 'log_level',
                        help = 'Print only error messages')
    parser.add_argument('--trace', action = 'store_true',
                        help = 'Print XML data sent and received')
   
    args = parser.parse_args()
    settings = XMPPSettings({
                            "software_name": "TCP Tunneler Bot"
                            })
    settings.load_arguments(args)

    if settings.get("password") is None:
        password = getpass("{0!r} password: "******"utf-8")
        settings["password"] = password

    if sys.version_info.major < 3:
        args.jid = args.jid.decode("utf-8")

    logging.basicConfig(level = args.log_level)
    if args.trace:
        print "enabling trace"
        handler = logging.StreamHandler()
        handler.setLevel(logging.DEBUG)
        for logger in ("pyxmpp2.IN", "pyxmpp2.OUT"):
            logger = logging.getLogger(logger)
            logger.setLevel(logging.DEBUG)
            logger.addHandler(handler)
            logger.propagate = False

    im_tcp_tunneler.setup_tunnels(args.tunnel_conf)

    global bot
    bot = Bot(JID(args.jid), settings)
    try:
        bot.run()
    except KeyboardInterrupt:
        bot.disconnect()
Example #3
0
def main():
    """Parse the command-line arguments and run the tool."""
    parser = argparse.ArgumentParser(description='XMPP version checker',
                                     parents=[XMPPSettings.get_arg_parser()])
    parser.add_argument('source', metavar='SOURCE', help='Source JID')
    parser.add_argument('target',
                        metavar='TARGET',
                        nargs='?',
                        help='Target JID (default: domain of SOURCE)')
    parser.add_argument('--debug',
                        action='store_const',
                        dest='log_level',
                        const=logging.DEBUG,
                        default=logging.INFO,
                        help='Print debug messages')
    parser.add_argument('--quiet',
                        const=logging.ERROR,
                        action='store_const',
                        dest='log_level',
                        help='Print only error messages')
    args = parser.parse_args()
    settings = XMPPSettings()
    settings.load_arguments(args)

    if settings.get("password") is None:
        password = getpass("{0!r} password: "******"utf-8")
        settings["password"] = password

    if sys.version_info.major < 3:
        args.source = args.source.decode("utf-8")

    source = JID(args.source)

    if args.target:
        if sys.version_info.major < 3:
            args.target = args.target.decode("utf-8")
        target = JID(args.target)
    else:
        target = JID(source.domain)

    logging.basicConfig(level=args.log_level)

    checker = VersionChecker(source, target, settings)
    try:
        checker.run()
    except KeyboardInterrupt:
        checker.disconnect()
Example #4
0
def main():
    """Parse the command-line arguments and run the bot."""
    parser = argparse.ArgumentParser(description="XMPP echo bot", parents=[XMPPSettings.get_arg_parser()])
    parser.add_argument("jid", metavar="JID", help="The bot JID")
    parser.add_argument(
        "--debug",
        action="store_const",
        dest="log_level",
        const=logging.DEBUG,
        default=logging.INFO,
        help="Print debug messages",
    )
    parser.add_argument(
        "--quiet", const=logging.ERROR, action="store_const", dest="log_level", help="Print only error messages"
    )
    parser.add_argument("--trace", action="store_true", help="Print XML data sent and received")

    args = parser.parse_args()
    settings = XMPPSettings({"software_name": "Echo Bot"})
    settings.load_arguments(args)

    if settings.get("password") is None:
        password = getpass("{0!r} password: "******"utf-8")
        settings["password"] = password

    if sys.version_info.major < 3:
        args.jid = args.jid.decode("utf-8")

    logging.basicConfig(level=args.log_level)
    if args.trace:
        print "enabling trace"
        handler = logging.StreamHandler()
        handler.setLevel(logging.DEBUG)
        for logger in ("pyxmpp2.IN", "pyxmpp2.OUT"):
            logger = logging.getLogger(logger)
            logger.setLevel(logging.DEBUG)
            logger.addHandler(handler)
            logger.propagate = False

    bot = EchoBot(JID(args.jid), settings)
    try:
        bot.run()
    except KeyboardInterrupt:
        bot.disconnect()
Example #5
0
def main():
    """Parse the command-line arguments and run the tool."""
    parser = argparse.ArgumentParser(description = 'XMPP version checker',
                                    parents = [XMPPSettings.get_arg_parser()])
    parser.add_argument('source', metavar = 'SOURCE', 
                                        help = 'Source JID')
    parser.add_argument('target', metavar = 'TARGET', nargs = '?',
                            help = 'Target JID (default: domain of SOURCE)')
    parser.add_argument('--debug',
                        action = 'store_const', dest = 'log_level',
                        const = logging.DEBUG, default = logging.INFO,
                        help = 'Print debug messages')
    parser.add_argument('--quiet', const = logging.ERROR,
                        action = 'store_const', dest = 'log_level',
                        help = 'Print only error messages')
    args = parser.parse_args()
    settings = XMPPSettings()
    settings.load_arguments(args)
    
    if settings.get("password") is None:
        password = getpass("{0!r} password: "******"utf-8")
        settings["password"] = password

    if sys.version_info.major < 3:
        args.source = args.source.decode("utf-8")

    source = JID(args.source)

    if args.target:
        if sys.version_info.major < 3:
            args.target = args.target.decode("utf-8")
        target = JID(args.target)
    else:
        target = JID(source.domain)

    logging.basicConfig(level = args.log_level)

    checker = VersionChecker(source, target, settings)
    try:
        checker.run()
    except KeyboardInterrupt:
        checker.disconnect()
Example #6
0
def main():
    """Parse the command-line arguments and run the bot."""
    parser = argparse.ArgumentParser(description = 'XMPP echo bot',
                                    parents = [XMPPSettings.get_arg_parser()])
    parser.add_argument('--debug',
                        action = 'store_const', dest = 'log_level',
                        const = logging.DEBUG, default = logging.INFO,
                        help = 'Print debug messages')
    parser.add_argument('--quiet', const = logging.ERROR,
                        action = 'store_const', dest = 'log_level',
                        help = 'Print only error messages')
    parser.add_argument('--trace', action = 'store_true',
                        help = 'Print XML data sent and received')
    parser.add_argument('--roster-cache',
                        help = 'Store roster in this file')
    parser.add_argument('jid', metavar = 'JID',
                                        help = 'The bot JID')
    subparsers = parser.add_subparsers(help = 'Action', dest = "action")
    show_p = subparsers.add_parser('show', help = 'Show roster and exit')
    show_p.add_argument('--presence', action = 'store_true',
                        help = 'Wait 5 s for contact presence information'
                                ' and display it with the roster')
    mon_p = subparsers.add_parser('monitor', help =
                                        'Show roster and subsequent changes')
    mon_p.add_argument('--presence', action = 'store_true',
                        help = 'Show contact presence changes too')
    add_p = subparsers.add_parser('add', help = 'Add an item to the roster')
    add_p.add_argument('--subscribe', action = 'store_true', dest = 'subscribe',
                        help = 'Request a presence subscription too')
    add_p.add_argument('--approve', action = 'store_true', dest = 'approve',
                        help = 'Pre-approve subscription from the contact'
                                                ' (requires server support)')
    add_p.add_argument('contact', metavar = 'CONTACT', help = 'The JID to add')
    add_p.add_argument('name', metavar = 'NAME', nargs = '?',
                                            help = 'Contact name')
    add_p.add_argument('groups', metavar = 'GROUP', nargs = '*',
                                            help = 'Group names')
    rm_p = subparsers.add_parser('remove',
                                    help = 'Remove an item from the roster')
    rm_p.add_argument('contact', metavar = 'CONTACT',
                                    help = 'The JID to remove')
    upd_p = subparsers.add_parser('update',
                                    help = 'Update an item in the roster')
    upd_p.add_argument('contact', metavar = 'CONTACT',
                                    help = 'The JID to update')
    upd_p.add_argument('name', metavar = 'NAME', nargs = '?',
                                            help = 'Contact name')
    upd_p.add_argument('groups', metavar = 'GROUP', nargs = '*',
                                            help = 'Group names')

    args = parser.parse_args()
    settings = XMPPSettings()
    settings.load_arguments(args)

    if settings.get("password") is None:
        password = getpass("{0!r} password: "******"utf-8")
        settings["password"] = password

    if sys.version_info.major < 3:
        args.jid = args.jid.decode("utf-8")
        if getattr(args, "contact", None):
            args.contact = args.contact.decode("utf-8")
        if getattr(args, "name", None):
            args.name = args.name.decode("utf-8")
        if getattr(args, "groups", None):
            args.groups = [g.decode("utf-8") for g in args.groups]

    logging.basicConfig(level = args.log_level)
    if args.trace:
        print "enabling trace"
        handler = logging.StreamHandler()
        handler.setLevel(logging.DEBUG)
        for logger in ("pyxmpp2.IN", "pyxmpp2.OUT"):
            logger = logging.getLogger(logger)
            logger.setLevel(logging.DEBUG)
            logger.addHandler(handler)
            logger.propagate = False

    if args.action == "monitor" or args.action == "show" and args.presence:
        # According to RFC6121 it could be None for 'monitor' (no need to send
        # initial presence to request roster), but Google seems to require that
        # to send roster pushes
        settings["initial_presence"] = Presence(priority = -1)
    else:
        settings["initial_presence"] = None

    tool = RosterTool(JID(args.jid), args, settings)
    try:
        tool.run()
    except KeyboardInterrupt:
        tool.disconnect()
Example #7
0
def main():
    import os
    from getpass import getpass
    import argparse
    from nicelogger import enable_pretty_logging
    from cli import repl
    """Parse the command-line arguments and run the bot."""
    parser = argparse.ArgumentParser(description='XMPP dev bot',
                                     parents=[XMPPSettings.get_arg_parser()])
    parser.add_argument('jid', metavar='JID', help='The bot JID')
    parser.add_argument('--debug',
                        action='store_const',
                        dest='log_level',
                        const=logging.DEBUG,
                        default=logging.INFO,
                        help='Print debug messages')
    parser.add_argument('--quiet',
                        const=logging.ERROR,
                        action='store_const',
                        dest='log_level',
                        help='Print only error messages')
    parser.add_argument('--trace',
                        action='store_true',
                        help='Print XML data sent and received')

    args = parser.parse_args()
    settings = XMPPSettings({"software_name": "pyxmpp2 Bot"})
    settings.load_arguments(args)
    if args.jid.endswith('@gmail.com'):
        settings['starttls'] = True
        settings['tls_verify_peer'] = False

    if settings.get("password") is None:
        password = getpass("{0!r} password: "******"password"] = password

    if args.trace:
        logging.info('enabling trace')
        for logger in ("pyxmpp2.IN", "pyxmpp2.OUT"):
            logger = logging.getLogger(logger)
            logger.setLevel(logging.DEBUG)
    enable_pretty_logging(level=args.log_level)

    bot = AutoAcceptBot(JID(args.jid), settings)

    class Q:
        def __call__(self):
            sys.exit()

        __repr__ = __call__

    q = Q()
    self = bot

    try:
        bot.connect()
        while True:
            try:
                bot.run()
            except KeyboardInterrupt:
                v = vars()
                v.update(globals())
                repl(v, os.path.expanduser('~/.xmppbot_history'))
    except SystemExit:
        bot.disconnect()
    except:
        bot.disconnect()
        import traceback
        traceback.print_exc()
Example #8
0
#!/usr/bin/python

from pyxmpp2.simple import send_message
from pyxmpp2.settings import XMPPSettings

argparser = XMPPSettings.get_arg_parser(add_help=True)
settings = XMPPSettings()
settings.load_arguments(argparser.parse_args())
from pyxmpp2.simple import send_message

# send_message("*****@*****.**", "bob's password", "*****@*****.**", "Hello Alice")

send_message(r'xyz\[email protected]', 'pwd', '*****@*****.**',
             'fuckoff')
Example #9
0
def main():
    """Parse the command-line arguments and run the bot."""
    parser = argparse.ArgumentParser(description="XMPP echo bot", parents=[XMPPSettings.get_arg_parser()])
    parser.add_argument(
        "--debug",
        action="store_const",
        dest="log_level",
        const=logging.DEBUG,
        default=logging.INFO,
        help="Print debug messages",
    )
    parser.add_argument(
        "--quiet", const=logging.ERROR, action="store_const", dest="log_level", help="Print only error messages"
    )
    parser.add_argument("--trace", action="store_true", help="Print XML data sent and received")
    parser.add_argument("--roster-cache", help="Store roster in this file")
    parser.add_argument("jid", metavar="JID", help="The bot JID")
    subparsers = parser.add_subparsers(help="Action", dest="action")
    show_p = subparsers.add_parser("show", help="Show roster and exit")
    show_p.add_argument(
        "--presence",
        action="store_true",
        help="Wait 5 s for contact presence information" " and display it with the roster",
    )
    mon_p = subparsers.add_parser("monitor", help="Show roster and subsequent changes")
    mon_p.add_argument("--presence", action="store_true", help="Show contact presence changes too")
    add_p = subparsers.add_parser("add", help="Add an item to the roster")
    add_p.add_argument("--subscribe", action="store_true", dest="subscribe", help="Request a presence subscription too")
    add_p.add_argument(
        "--approve",
        action="store_true",
        dest="approve",
        help="Pre-approve subscription from the contact" " (requires server support)",
    )
    add_p.add_argument("contact", metavar="CONTACT", help="The JID to add")
    add_p.add_argument("name", metavar="NAME", nargs="?", help="Contact name")
    add_p.add_argument("groups", metavar="GROUP", nargs="*", help="Group names")
    rm_p = subparsers.add_parser("remove", help="Remove an item from the roster")
    rm_p.add_argument("contact", metavar="CONTACT", help="The JID to remove")
    upd_p = subparsers.add_parser("update", help="Update an item in the roster")
    upd_p.add_argument("contact", metavar="CONTACT", help="The JID to update")
    upd_p.add_argument("name", metavar="NAME", nargs="?", help="Contact name")
    upd_p.add_argument("groups", metavar="GROUP", nargs="*", help="Group names")

    args = parser.parse_args()
    settings = XMPPSettings()
    settings.load_arguments(args)

    if settings.get("password") is None:
        password = getpass("{0!r} password: "******"utf-8")
        settings["password"] = password

    if sys.version_info.major < 3:
        args.jid = args.jid.decode("utf-8")
        if getattr(args, "contact", None):
            args.contact = args.contact.decode("utf-8")
        if getattr(args, "name", None):
            args.name = args.name.decode("utf-8")
        if getattr(args, "groups", None):
            args.groups = [g.decode("utf-8") for g in args.groups]

    logging.basicConfig(level=args.log_level)
    if args.trace:
        print "enabling trace"
        handler = logging.StreamHandler()
        handler.setLevel(logging.DEBUG)
        for logger in ("pyxmpp2.IN", "pyxmpp2.OUT"):
            logger = logging.getLogger(logger)
            logger.setLevel(logging.DEBUG)
            logger.addHandler(handler)
            logger.propagate = False

    if args.action == "monitor" or args.action == "show" and args.presence:
        # According to RFC6121 it could be None for 'monitor' (no need to send
        # initial presence to request roster), but Google seems to require that
        # to send roster pushes
        settings["initial_presence"] = Presence(priority=-1)
    else:
        settings["initial_presence"] = None

    tool = RosterTool(JID(args.jid), args, settings)
    try:
        tool.run()
    except KeyboardInterrupt:
        tool.disconnect()
Example #10
0
def main():
    """Parse the command-line arguments and run the bot."""
    parser = argparse.ArgumentParser(description = 'XMPP echo bot',
                                    parents = [XMPPSettings.get_arg_parser()])
    parser.add_argument('--debug',
                        action = 'store_const', dest = 'log_level',
                        const = logging.DEBUG, default = logging.INFO,
                        help = 'Print debug messages')
    parser.add_argument('--quiet', const = logging.ERROR,
                        action = 'store_const', dest = 'log_level',
                        help = 'Print only error messages')
    parser.add_argument('--trace', action = 'store_true',
                        help = 'Print XML data sent and received')
    parser.add_argument('--roster-cache', 
                        help = 'Store roster in this file')
    parser.add_argument('jid', metavar = 'JID', 
                                        help = 'The bot JID')
    subparsers = parser.add_subparsers(help = 'Action', dest = "action")
    show_p = subparsers.add_parser('show', help = 'Show roster and exit')
    show_p.add_argument('--presence', action = 'store_true',
                        help = 'Wait 5 s for contact presence information'
                                ' and display it with the roster')
    mon_p = subparsers.add_parser('monitor', help = 
                                        'Show roster and subsequent changes')
    mon_p.add_argument('--presence', action = 'store_true',
                        help = 'Show contact presence changes too')
    add_p = subparsers.add_parser('add', help = 'Add an item to the roster')
    add_p.add_argument('--subscribe', action = 'store_true', dest = 'subscribe',
                        help = 'Request a presence subscription too')
    add_p.add_argument('--approve', action = 'store_true', dest = 'approve',
                        help = 'Pre-approve subscription from the contact'
                                                ' (requires server support)')
    add_p.add_argument('contact', metavar = 'CONTACT', help = 'The JID to add')
    add_p.add_argument('name', metavar = 'NAME', nargs = '?',
                                            help = 'Contact name')
    add_p.add_argument('groups', metavar = 'GROUP', nargs = '*',
                                            help = 'Group names')
    rm_p = subparsers.add_parser('remove',
                                    help = 'Remove an item from the roster')
    rm_p.add_argument('contact', metavar = 'CONTACT',
                                    help = 'The JID to remove')
    upd_p = subparsers.add_parser('update', 
                                    help = 'Update an item in the roster')
    upd_p.add_argument('contact', metavar = 'CONTACT',
                                    help = 'The JID to update')
    upd_p.add_argument('name', metavar = 'NAME', nargs = '?',
                                            help = 'Contact name')
    upd_p.add_argument('groups', metavar = 'GROUP', nargs = '*',
                                            help = 'Group names')

    args = parser.parse_args()
    settings = XMPPSettings()
    settings.load_arguments(args)

    if settings.get("password") is None:
        password = getpass("{0!r} password: "******"utf-8")
        settings["password"] = password

    if sys.version_info.major < 3:
        args.jid = args.jid.decode("utf-8")
        if getattr(args, "contact", None):
            args.contact = args.contact.decode("utf-8")
        if getattr(args, "name", None):
            args.name = args.name.decode("utf-8")
        if getattr(args, "groups", None):
            args.groups = [g.decode("utf-8") for g in args.groups]

    logging.basicConfig(level = args.log_level)
    if args.trace:
        print "enabling trace"
        handler = logging.StreamHandler()
        handler.setLevel(logging.DEBUG)
        for logger in ("pyxmpp2.IN", "pyxmpp2.OUT"):
            logger = logging.getLogger(logger)
            logger.setLevel(logging.DEBUG)
            logger.addHandler(handler)
            logger.propagate = False
           
    if args.action == "monitor" or args.action == "show" and args.presence:
        # According to RFC6121 it could be None for 'monitor' (no need to send
        # initial presence to request roster), but Google seems to require that
        # to send roster pushes
        settings["initial_presence"] = Presence(priority = -1)
    else:
        settings["initial_presence"] = None

    tool = RosterTool(JID(args.jid), args, settings)
    try:
        tool.run()
    except KeyboardInterrupt:
        tool.disconnect()
Example #11
0
def main():
  import os
  from getpass import getpass
  import argparse
  from nicelogger import enable_pretty_logging
  from cli import repl

  """Parse the command-line arguments and run the bot."""
  parser = argparse.ArgumentParser(description = 'XMPP dev bot',
                  parents = [XMPPSettings.get_arg_parser()])
  parser.add_argument('jid', metavar = 'JID',
                    help = 'The bot JID')
  parser.add_argument('--debug',
            action = 'store_const', dest = 'log_level',
            const = logging.DEBUG, default = logging.INFO,
            help = 'Print debug messages')
  parser.add_argument('--quiet', const = logging.ERROR,
            action = 'store_const', dest = 'log_level',
            help = 'Print only error messages')
  parser.add_argument('--trace', action = 'store_true',
            help = 'Print XML data sent and received')

  args = parser.parse_args()
  settings = XMPPSettings({
    "software_name": "pyxmpp2 Bot"
  })
  settings.load_arguments(args)
  if args.jid.endswith('@gmail.com'):
    settings['starttls'] = True
    settings['tls_verify_peer'] = False

  if settings.get("password") is None:
    password = getpass("{0!r} password: "******"password"] = password

  if args.trace:
    logging.info('enabling trace')
    for logger in ("pyxmpp2.IN", "pyxmpp2.OUT"):
      logger = logging.getLogger(logger)
      logger.setLevel(logging.DEBUG)
  enable_pretty_logging(level=args.log_level)

  bot = AutoAcceptBot(JID(args.jid), settings)

  class Q:
    def __call__(self):
      sys.exit()
    __repr__ = __call__

  q = Q()
  self = bot

  try:
    bot.connect()
    while True:
      try:
        bot.run()
      except KeyboardInterrupt:
        v = vars()
        v.update(globals())
        repl(v, os.path.expanduser('~/.xmppbot_history'))
  except SystemExit:
    bot.disconnect()
  except:
    bot.disconnect()
    import traceback
    traceback.print_exc()
Example #12
0
#!/usr/bin/python

from pyxmpp2.simple import send_message
from pyxmpp2.settings import XMPPSettings

argparser = XMPPSettings.get_arg_parser(add_help = True)
settings = XMPPSettings()
settings.load_arguments(argparser.parse_args())
from pyxmpp2.simple import send_message

# send_message("*****@*****.**", "bob's password", "*****@*****.**", "Hello Alice")

send_message(r'xyz\[email protected]', 'pwd', '*****@*****.**', 'fuckoff')