gnu-emacs-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AIMFight.com for emacs


From: mzsanford
Subject: AIMFight.com for emacs
Date: 14 Dec 2005 10:31:13 -0800
User-agent: G2/0.2

;; first ever lisp. non emacs user, but too interesting to pass up

(provide 'aim-fight)

(defvar aim-fight-base "http://aimfight.com/getFight.php?name1=";)
(defvar aim-fight-mid "&name2=")
(defvar aim-fight-sn "YOUR_SCREENNAME_HERE")

(make-variable-buffer-local 'aim-fight)

(defun aim-fight-get-url (string)
  (interactive)
  (message "URL: %s" string)
  (let ((local-buffer (get-buffer-create "aim-fight-buffer")))
  (call-process "curl" nil local-buffer nil "-s" string)
  (set-buffer local-buffer)
  (let ((myStr (buffer-string)))
    (if (string-match "height1=\\([0-9]+\\)&height2=\\([0-9]+\\)"
myStr)
      (let ((w (match-string 1 myStr))
            (h (match-string 2 myStr)))
          (if (> (string-to-number w) (string-to-number h)) (message
"You Win") (message "You Lose"))
      )
    )
  )
  (kill-buffer local-buffer)
  )
)

(defun aim-fight-do-fight (string)
  (interactive)
  (aim-fight-get-url (concat aim-fight-base aim-fight-sn aim-fight-mid
string)))

(defun aim-fight (string)
  "Get AIM Fight resut"
  (interactive "sEnemy: ")
  (aim-fight-do-fight string))

(global-set-key "\C-xa" 'aim-fight)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]