Commits

Ada Young committed 98c53f2

Warpdb, first commit!

Comments (0)

Files changed (1)

+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE muclient>
+<!-- Saved on Monday, December 03, 2012, 12:00 PM -->
+<!-- MuClient version 4.77 -->
+
+<!-- Plugin "WarpDB" generated by Plugin Wizard -->
+
+<muclient>
+<plugin
+   name="WarpDB"
+   author="Ada"
+   id="ae5f1227fd39d40fa64beadf"
+   language="Python"
+   purpose="Warp Database"
+   date_written="2012-12-30 12:00:00"
+   requires="4.62"
+   version="1.0"
+   >
+<description trim="y">
+<![CDATA[
+I'm a serpent and I often wonder which warp to take to reach a given area from a given area. This plugin addresses the problem with a warp database which may be looked up for such assistance. Have a look at the available aliases to interact with it. I'll add the ability to work with ATCP/GMCP information and open some possibility to work with a mapper in later versions.
+
+This plugin is written in Python, please see this page to setup Python on your computer: http://adayoung.bitbucket.org/pythonsqlite.html
+
+The following aliases are available:
+
+    WarpDB:sources - Check for warps in your area and add them to database
+    WarpDB:toarea <area name> - Check for warps leading to the specified area from your location
+    WarpDB:endpoints - Display a list of all areas you can reach from your location
+    WarpDB:search from:<area name> to:<area name> - Display a list of warps connecting the specified areas
+
+The plugin will ask you for a file location on first load, just point it wherever you want your database file to be created. If you get "OperationalError: database is locked" error while trying to add an entry, please delete the .journal file in %APPDATA%\MUSHClient to resolve the issue.
+]]>
+</description>
+
+</plugin>
+
+<!--  Get our standard constants -->
+
+<include name="constants.pys"/>
+
+<!--  Triggers  -->
+
+<!--  Aliases  -->
+
+<aliases>
+  <alias
+   match="^WarpDB:test (.*?)$"
+   enabled="y"
+   regexp="y"
+   send_to="12"
+   ignore_case="y"
+   sequence="100"
+  >
+  <send>exec("%1")</send>
+  </alias>
+</aliases>
+
+<!--  Script  -->
+
+<script>
+<![CDATA[
+import re
+import sqlite3
+from datetime import datetime, timedelta
+
+import Tkinter
+root = Tkinter.Tk()
+root.withdraw() # to hide the Tk GUI window as per http://stackoverflow.com/a/1796726
+
+from tkFileDialog import asksaveasfilename, askopenfilename
+
+def Note(message): # not writing world.Note everywhere ^_^
+    world.Note(message)
+
+DBFile = world.GetVariable("dbpath")
+if not DBFile:
+    while not (DBFile and len(DBFile) > 0):
+        DBFile = asksaveasfilename(defaultextension=".db", filetypes=[("SQLite3 database file", "*.db")], title="Specify the location of your new database.")
+    world.SetVariable("dbpath", DBFile)
+    world.SaveState
+
+db = sqlite3.connect(DBFile)
+cursor = db.cursor()
+
+def createdb():
+    cursor.execute("PRAGMA foreign_keys=ON")
+    cursor.execute("""
+    CREATE TABLE IF NOT EXISTS arealist (
+        id INTEGER PRIMARY KEY AUTOINCREMENT,
+        arealist TEXT UNIQUE
+    )""")
+    cursor.execute("""
+    CREATE TABLE IF NOT EXISTS warplist (
+        id INTEGER PRIMARY KEY AUTOINCREMENT,
+        source TEXT,
+        destination TEXT,
+        source_areaid INTEGER REFERENCES arealist(id) ON DELETE CASCADE
+    )""")
+    cursor.execute("""
+    CREATE INDEX IF NOT EXISTS logs_index ON org_logs (orgid, timestamp, message)
+    """)
+    db.commit()
+
+createdb()
+]]>
+</script>
+
+<!--  Plugin help  -->
+
+<aliases>
+  <alias
+   script="OnHelp"
+   match="WarpDB:help"
+   ignore_case="y"
+   enabled="y"
+  >
+  </alias>
+</aliases>
+
+<script>
+<![CDATA[
+def OnHelp (a, b, c):
+    world.note (world.GetPluginInfo (world.GetPluginID, 3))
+]]>
+</script>
+
+</muclient>