Example #1
0
def autoclean(db):
  for (a_id,) in db.prepare("select id from addresses where domain=2 and text like 'RU.LIST.%'"):
    n = db.prepare("select count(*) from messages where destination=$1").first(a_id)
    print (a_id, n)
    if n==0:
      oblive(db, ftnconfig.get_taddr(db, a_id))

  ok4441=set(map(str.strip, open("4441").readlines()))
  my4441=set(map(str.strip, open("4441my").readlines()))
  for (a_id, a_text) in db.prepare("select id, text from addresses where domain=2"):
    if a_text in my4441 and a_text not in ok4441:
      n = db.prepare("select count(*) from messages where destination=$1").first(a_id)
      if n==0:
        print (a_text)
        oblive(db, ftnconfig.get_taddr(db, a_id))
Example #2
0
def oblive(db, address):
  robot = ftnconfig.robotnames[address[0]]

  addr_id = ftnconfig.get_taddr_id(db, address)
  if addr_id is None:
    raise Exception("not found")

  msg_from = db.prepare("select count (*) from messages where source=$1").first(addr_id)
  msg_to = db.prepare("select count (*) from messages where destination=$1").first(addr_id)
  print (address, addr_id, "from:", msg_from, "to:", msg_to)

  if msg_from!=0 or msg_to!=0:
    print("messages exist")
    return
#  assert( input("enter 'yes' to confirm: ")=="yes" )

  with ftnimport.session(db) as sess:
    for (link_addr,subs_id) in db.prepare("select a.text, s.id from addresses a, subscriptions s where a.id=s.subscriber and s.target=$1")(addr_id):
      print ("unsubscribing",link_addr)
      link_id = ftnconfig.find_link(db, link_addr)
      my_id, pw=ftnaccess.link_password(db, link_id, forrobots=True)
      sess.send_message(ftnconfig.get_taddr(db, my_id), ftnconfig.SYSOP, ("node", link_addr), robot, None, pw, "-"+address[1], sendmode="direct")
      db.prepare("delete from subscriptions where id=$1")(subs_id)
    sess.send_message(("node", ftnconfig.ADDRESS), ftnconfig.SYSOP, ("echo", "FLUID.LOCAL"), "All", None, "removal", address[0]+" "+address[1]+" removed from node")
    db.prepare("delete from deletedvitalsubscriptionwatermarks where target=$1")(addr_id)
    db.prepare("delete from addresses where id=$1")(addr_id)
Example #3
0
def fix(db, sess, src, srcname, destname, domain, password, msgid, cmdtext, is_local):
  dom, text = db.prepare("select domain, text from addresses where id=$1").first(src)
  if dom != db.FTN_domains["node"]:
    raise FTNFail("not our domain")
  print(text)
  link_id, addr_id, myaddr_id = ftnaccess.check_link(db, text, password, True)
  if myaddr_id is None:
    reply=["wrong password"]
  elif link_id is None:
    reply=["unknown link"]
  elif not is_local:
    reply=["request delivered not directly, please consider changing the password"]
  else:
    reply=[]
    for cmd in map(str.strip, cmdtext.upper().strip().split("\n")):
      if cmd.startswith("---"):
        break
      elif len(cmd)==0:
        continue
      elif cmd.startswith("%PING"):
        reply.append("NOP: "+cmd)
      elif cmd.startswith("%QUERY"):
        for area in ftnexport.get_node_subscriptions(db, text, domain):
          reply.append(area)
      elif cmd.startswith("%HELP"):
        reply.append("Use following command:")
        reply.append("  %QUERY          -- list of subscribed areas")
        reply.append("  %LIST           -- list of all areas")
        reply.append("  +areaname       -- subscribe, or:")
        reply.append("  areaname        -- subscribe")
        reply.append("  -areaname       -- unsubscribe")
        reply.append("        you can use ? to substitite any one character an area name")
        reply.append("        or * to substitude any number of any characters in area name")
        reply.append("        areaname must be UPPERCASE")
        reply.append("  %RESET area YYYY-MM-DD -- reset area to specified date")
        reply.append("")
      elif cmd.startswith("%LIST"):
        for area in ftnexport.get_all_targets(db, domain):
          reply.append(area)
      elif cmd.startswith("%AVAIL"):
        reply.append("Sorry not implemented: "+cmd)
      elif cmd.startswith("%PAUSE"):
        reply.append("Sorry not implemented: "+cmd)
      elif cmd.startswith("%RESET"):
        reply += reset(db, sess, text, domain, cmd[7:])
      elif cmd.startswith("-"):
        reply += unsubscribe(db, sess, text, domain, cmd[1:])
      elif cmd.startswith("+"):
        reply += subscribe(db, sess, text, domain, cmd[1:])
      elif cmd.startswith("%"):
        reply.append("Unknown command: "+cmd)
        print(cmd)
#        1/0
      else:
        reply+=subscribe(db, sess, text, domain, cmd)

  reply.append("")
  sess.send_message(ftnconfig.get_taddr(db, myaddr_id), destname+" Robot", ("node", text), srcname, msgid, "report", "\n".join(reply), sendmode="direct")
  print(reply)
Example #4
0
def autoclean(db):
    for (a_id, ) in db.prepare(
            "select id from addresses where domain=2 and text like 'RU.LIST.%'"
    ):
        n = db.prepare(
            "select count(*) from messages where destination=$1").first(a_id)
        print(a_id, n)
        if n == 0:
            oblive(db, ftnconfig.get_taddr(db, a_id))

    ok4441 = set(map(str.strip, open("4441").readlines()))
    my4441 = set(map(str.strip, open("4441my").readlines()))
    for (a_id, a_text
         ) in db.prepare("select id, text from addresses where domain=2"):
        if a_text in my4441 and a_text not in ok4441:
            n = db.prepare("select count(*) from messages where destination=$1"
                           ).first(a_id)
            if n == 0:
                print(a_text)
                oblive(db, ftnconfig.get_taddr(db, a_id))
Example #5
0
def oblive(db, address):
    robot = ftnconfig.robotnames[address[0]]

    addr_id = ftnconfig.get_taddr_id(db, address)
    if addr_id is None:
        raise Exception("not found")

    msg_from = db.prepare(
        "select count (*) from messages where source=$1").first(addr_id)
    msg_to = db.prepare(
        "select count (*) from messages where destination=$1").first(addr_id)
    print(address, addr_id, "from:", msg_from, "to:", msg_to)

    if msg_from != 0 or msg_to != 0:
        print("messages exist")
        return


#  assert( input("enter 'yes' to confirm: ")=="yes" )

    with ftnimport.session(db) as sess:
        for (link_addr, subs_id) in db.prepare(
                "select a.text, s.id from addresses a, subscriptions s where a.id=s.subscriber and s.target=$1"
        )(addr_id):
            print("unsubscribing", link_addr)
            link_id = ftnconfig.find_link(db, link_addr)
            my_id, pw = ftnaccess.link_password(db, link_id, forrobots=True)
            sess.send_message(ftnconfig.get_taddr(db, my_id),
                              ftnconfig.SYSOP, ("node", link_addr),
                              robot,
                              None,
                              pw,
                              "-" + address[1],
                              sendmode="direct")
            db.prepare("delete from subscriptions where id=$1")(subs_id)
        sess.send_message(("node", ftnconfig.ADDRESS), ftnconfig.SYSOP,
                          ("echo", "FLUID.LOCAL"), "All", None, "removal",
                          address[0] + " " + address[1] + " removed from node")
        db.prepare(
            "delete from deletedvitalsubscriptionwatermarks where target=$1")(
                addr_id)
        db.prepare("delete from addresses where id=$1")(addr_id)
Example #6
0
  cmd = sys.argv[1]
  domain = sys.argv[2]
  area = sys.argv[3]
  subscriber = sys.argv[4]
except:
  print("usage: ./util_subscription.py add|addvital|remove echo|fileecho AREANAME 2:5020/9999")
  exit()

try:
  robot = ftnconfig.robotnames[domain]
except:
  raise Exception("cannot manage subscriptions in domain", domain)

link_id = ftnconfig.find_link(db, subscriber)
my_id, pw = ftnaccess.link_password(db, link_id, forrobots=True)
my_addr = ftnconfig.get_taddr(db, my_id)

with ftnimport.session(db) as sess:
  if cmd == "add":
    try:
      sess.add_subscription(None, domain, area, subscriber)
    except FTNAlreadySubscribed:
      print ("local subscription exists")
    if subscriber != ftnconfig.ADDRESS:
      sess.send_message(my_addr, ftnconfig.SYSOP, ("node", subscriber), robot, None, pw, "+"+area, sendmode="direct")
    else:
      print ("local subscription")

  elif cmd == "remove":
    sess.remove_subscription(domain, area, subscriber)
    if subscriber != ftnconfig.ADDRESS:
Example #7
0
    area = sys.argv[3]
    subscriber = sys.argv[4]
except:
    print(
        "usage: ./util_subscription.py add|addvital|remove echo|fileecho AREANAME 2:5020/9999"
    )
    exit()

try:
    robot = ftnconfig.robotnames[domain]
except:
    raise Exception("cannot manage subscriptions in domain", domain)

link_id = ftnconfig.find_link(db, subscriber)
my_id, pw = ftnaccess.link_password(db, link_id, forrobots=True)
my_addr = ftnconfig.get_taddr(db, my_id)

with ftnimport.session(db) as sess:
    if cmd == "add":
        try:
            sess.add_subscription(None, domain, area, subscriber)
        except FTNAlreadySubscribed:
            print("local subscription exists")
        if subscriber != ftnconfig.ADDRESS:
            sess.send_message(my_addr,
                              ftnconfig.SYSOP, ("node", subscriber),
                              robot,
                              None,
                              pw,
                              "+" + area,
                              sendmode="direct")
Example #8
0
def fix(db, sess, src, srcname, destname, domain, password, msgid, cmdtext,
        is_local):
    dom, text = db.prepare(
        "select domain, text from addresses where id=$1").first(src)
    if dom != db.FTN_domains["node"]:
        raise FTNFail("not our domain")
    print("*fix for:", text)
    link_id, addr_id, myaddr_id = ftnaccess.check_link(db, text, password,
                                                       True)
    if myaddr_id is None:
        reply = ["wrong password"]
        raise (Exception("cannot find my address to reply to *fix message"))
    elif link_id is None:
        reply = ["unknown link"]
    elif not is_local:
        reply = [
            "request delivered not directly, please consider changing the password"
        ]
    else:
        reply = []
        for cmd in map(str.strip, cmdtext.upper().strip().split("\n")):
            if cmd.startswith("---"):
                break
            elif len(cmd) == 0:
                continue
            elif cmd.startswith("%PING"):
                reply.append("NOP: " + cmd)
            elif cmd.startswith("%QUERY"):
                for area in ftnexport.get_node_subscriptions(db, text, domain):
                    reply.append(area)
            elif cmd.startswith("%HELP"):
                reply.append("Use following command:")
                reply.append("  %QUERY          -- list of subscribed areas")
                reply.append("  %LIST           -- list of all areas")
                reply.append("  +areaname       -- subscribe, or:")
                reply.append("  areaname        -- subscribe")
                reply.append("  -areaname       -- unsubscribe")
                reply.append(
                    "        you can use ? to substitite any one character an area name"
                )
                reply.append(
                    "        or * to substitude any number of any characters in area name"
                )
                reply.append("        areaname must be UPPERCASE")
                reply.append(
                    "  %RESET area YYYY-MM-DD -- reset area to specified date")
                reply.append("")
            elif cmd.startswith("%LIST"):
                for area in ftnexport.get_all_targets(db, domain):
                    reply.append(area)
            elif cmd.startswith("%AVAIL"):
                reply.append("Sorry not implemented: " + cmd)
            elif cmd.startswith("%PAUSE"):
                reply.append("Sorry not implemented: " + cmd)
            elif cmd.startswith("%RESET"):
                reply += reset(db, sess, text, domain, cmd[7:])
            elif cmd.startswith("-"):
                reply += unsubscribe(db, sess, text, domain, cmd[1:])
            elif cmd.startswith("+"):
                reply += subscribe(db, sess, text, domain, cmd[1:])
            elif cmd.startswith("%"):
                reply.append("Unknown command: " + cmd)
                print(cmd)
#        1/0
            else:
                reply += subscribe(db, sess, text, domain, cmd)

    reply.append("")
    print("*fix reply from:", myaddr_id, ftnconfig.get_taddr(db, myaddr_id))
    sess.send_message(ftnconfig.get_taddr(db, myaddr_id),
                      destname + " Robot", ("node", text),
                      srcname,
                      msgid,
                      "report",
                      "\n".join(reply),
                      sendmode="direct")
    print(reply)