PtokaX forum

Development Section => LUA & PtokaX-Scripting-Interface => Topic started by: GeceBekcisi on 04 July, 2005, 19:31:59

Title: How to send messages to OpChat?
Post by: GeceBekcisi on 04 July, 2005, 19:31:59
How can I send messages to opchat? This didnt work:sBot = frmHub:GetHubBotName()
sOpChat = frmHub:GetOpChatName()
SendPmToNick(sBot, sOpChat, "message to send opchat")
Title:
Post by: jiten on 04 July, 2005, 19:49:35
In that code of yours, you're sending the message to sBot :D
Check this:
SendPmToNick(ToNick, FromNick, Data) - Data without ending | !Maybe you should try this:
SendPmToOps(frmHub:GetOpChatName(), "message to send")
Cheers
Title:
Post by: GeceBekcisi on 04 July, 2005, 20:29:34
I was trying to write an report bot but I screwed up. I need help... It doesnt accept more than 1 words as reason..--// ==================================================
--// Simple UserReport  by GeceBekcisi
--// ==================================================

sBot = frmHub:GetHubBotName()
sOpChat = frmHub:GetOpChatName()
function ChatArrival(curUser, data)
local data = string.sub(data,1, -2)
local s,e,cmd = string.find(data, "%b<>%s[%!%+%?%#%+](%S+)")
if (cmd == "report") then
local s,e,nick,reason  = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)")
if (nick == nil or nick == "") then
curUser:SendData(sBot, "*** Nick is missing. Usage: !report ")
else
if (reason == nil or reason == "") then
curUser:SendData(sBot, "*** Reason is missing. Usage: !report ")
else
curUser:SendData(sBot, "You have successfully reported "..nick.." to operators.")
SendPmToOps(sOpChat, "\r\n\r\n=================================================="..
"\r\n\r\n\tReporter's Name\t\t: "..curUser.sName.."\r\n\t"..
"Reported Person's Name\t: "..nick.."\r\n\tReason for Report"..
"\t\t: "..reason.."\r\n\r\n"..
"==================================================\r\n")
end
end
return 1
end
end
Title:
Post by: jiten on 04 July, 2005, 21:13:08
Change:
local s,e,nick,reason  = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)")

to:
local s,e,nick,reason  = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")

Cheers
Title: Re: How to send messages to OpChat?
Post by: Znupi on 10 June, 2006, 14:07:10
A bit mor complicated report bottie :D

--[[

--== RepOrT BoT bY Znupi ==--

]]--

Bot = frmHub:GetHubBotName()
prefix = "!"

function ChatArrival(user,data)
data = string.sub(data,1,string.len(data)-1)
s,e,cmd=string.find(data,"%s+(%S+)(.*)")
if (cmd == prefix.."report") then
s,e,cmd,nick,reason = string.find(data,"%s+(%S+)%s+(%S+)(.*)")
if (reason == "") then
user:SendData(Bot,"Please add a reason to your report.")
user:SendData(Bot,"Report failed !")
user:SendData(Bot,"Report syntax: !report <user> <reason>")
return 1
end
rep = GetItemByName(nick)
if (rep == nil) then
SendPmToOps(frmHub:GetOpChatName(),user.sName.." reported "..nick.." (user offline) with reason: "..reason)
user:SendData(Bot,"Report succesful !")
return 1
end
if (rep ~= nil ) then
if (rep.bOperator) then
user:SendData(Bot,"Don't even think of reporting an op !")
return 1
else
SendPmToOps(frmHub:GetOpChatName(),user.sName.." reported "..nick.." (user online) with reason: "..reason)
user:SendData(Bot,"Report succesful !")
return 1
end
end

end
end

Tested it and it works just fine ...
Features:
+reports to ops if user is online/offline
+An op cannot be reported
Hope its usefull ...
Title: Re: How to send messages to OpChat?
Post by: bastya_elvtars on 11 June, 2006, 02:33:02
If I were you, I'd do the following:
1) Collect the available profiles.
2) Choose the ones that have OpChat enabled.
3) Send to users of the given profiles on a relevant event.
Title: Re: How to send messages to OpChat?
Post by: Markitos on 11 June, 2006, 10:11:07
Plus ur "string.finded" bad...check the lua wiki and your problems will be solved  ;D