Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Mar 06, 2009 12:28 am   

Automatic TMS voting with LuaSocket
 
I've been fiddling with LuaSocket's POST method support for a while trying to get an automatic voter for TMS working. This script won't vote without you having to do anything - it's not against TMS' rules to do that, but I don't think it's very sporting. You could make an alarm or something to run your vote every however often, but your vote will only be counted once every 12 hours no matter what you do.

What this script will do is vote for you from CMUD - all you need to do is type "vote" on the command line and hit enter. Very useful.

Here is the code of the alias; it's also available on the package library under the name "TMS Voter".

Code:
<alias name="vote" language="Lua">
  <value><![CDATA[if not http then http = require("socket.http") end

print("Connecting to grab info...")
local page = http.request("PUT YOUR MUD'S VOTE URL HERE")
local vtid = string.match(page,'<input type="hidden" name="vtid1" value="(%x+)">')
local mudid = string.match(page,'<input type="hidden" name="mudid" value="(%d+)">')
print("Have info, voting now...")
local r, c = http.request("http://www.topmudsites.com/vote.php","vtid1=" .. vtid .. "&mudid=" .. mudid .. "&do=in")
if c == 301 then
  print("Voting successful.")
else
  print("Voting failed, error code " .. c)
end]]></value>
</alias>


This script requires the LuaSocket library for Lua - instructions on how to install that are here. You will also need to put your MUD's vote URL into the script on line 5 of the alias. Your vote url should look like http://www.topmudsites.com/vote-fangxianfu.html and the http is required. Line 5 would then look like local page = http.request("http://www.topmudsites.com/vote-fangxianfu.html") and then you're set. Click Save at the top of the package editor to save your changes and then just type "vote" and you'll vote for your MUD.

Note that some MUDs utilise a provision in TMS' rules that lets users opt in to be bugged about votes. The MUD will generally notice when you vote and then stop bugging you until it's time to vote again. If your MUD does this, then your vote url should look slightly different. IRE users, for example, will have a vote url that looks like http://www.ironrealms.com/irex/tmsvote.php?id=achaea or something. You need to put that into the script instead for the MUD to know that you've voted and stop bugging you. If you're having trouble with this part, post a reply below.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net