· 6 years ago · May 14, 2019, 06:28 PM
1bot_name = "InviteGen"
2bot_email = "create@invite.code"
3bot_desc = "Sole purpose of this bot is to create uuid's to invite new users. <InviteGen V:1.0a,M:A,H:0/0/1,S:0>"
4bot_conn = "Bot"
5bot_share = 0
6bot_class = 3
7
8function Main()
9 VH:RegBot(bot_name, bot_class, bot_desc, string.char (2), bot_email, bot_share)
10 VH:SQLQuery("CREATE TABLE IF NOT EXISTS invites ( ´id´ INT AUTO_INCREMENT, ´key´ VARCHAR(30) NOT NULL, ´activated´ TINYINT(1), PRIMARY KEY (´id´)) AUTO_INCREMENT=1")
11end
12
13function UnLoad()
14 VH:UnRegBot(bot_name)
15end
16
17local random = math.random
18local function uuid()
19 local template ='xxxxx-xxxxx-xxxxx-xxxxx-xxxxx'
20 return string.gsub(template, '[x]', function (c)
21 local v = (c == 'x') and random(0, 0xf) or random(8, 0xb)
22 return string.format('%x', v)
23 end)
24end
25
26
27function VH_OnParsedMsgPM (nick, data, dest)
28 result, class = VH:GetUserClass(nick)
29 if dest == bot_name and class >= 5 then
30 if data == "!invitegen" then
31 invitekey = uuid()
32 result, count = VH:SQLQuery ("INSERT INTO invites (´key´, ´activated´) VALUES ('"..invitekey.."', 0)")
33 VH:SendToOpChat("Invite Code generated: " .. invitekey .. "|")
34 end
35 end
36 return 1
37end