mainchat command
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

mainchat command

Started by lynyrd, 23 February, 2004, 14:55:44

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

lynyrd

hi im trying to learn lua
i hope this is the right place to write..
i would like to know how i get a bot to recieve a command thru mainchat instead of a pm
i really tried to but failed so please help a noob =)

i beleive it's the "$To: i have to change??

code:
------------------------------------------------------------------------
function DataArrival(user, data)
if(strsub(data, 1, 4) == "$To:") then  
data=strsub(data,1,strlen(data)-1)  
s,e,whoTo,from,msg = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.+)")  
if (whoTo == botname) then
if nick[user.sName] ~= nil then
nick[user.sName] = nil
SaveToFile(user.sName,fname,nick)
PmToAStupidTablesGrrrButIAmStartingToLikeThemLOL(msg,from,user.sName)
nick[user.sName]=user.sName
SaveToFile(user.sName,fname,nick)
else
user:SendPM(botname,"Du har inte tilltr?de till detta rum!!!")
end
end
end
end
------------------------------------------------------------------------

RobinHood

Try this :-)

code:

function DataArrival(user,data)
   if (strsub(data, 1, 1) == "<") then
      data = strsub(data,1,strlen(data)-1)
      s,e,cmd,arg = strfind(data, "%b<>%s+(%S+)%s(.*)")
      if (arg==nil) then
         s,e,cmd = strfind(data, "%b<>%s+(%S+)%s*")
      end
      if (cmd=="!command") then
         SendToAll(botname, "test")
      end
   end
end

lynyrd

thanks robin hood im starting to get somewhere =)
i did this

code:
------------------------------------------------------------------------
function DataArrival(user,data)
if (strsub(data, 1, 1) == "<") then
data = strsub(data,1,strlen(data)-1)
s,e,cmd,arg = strfind(data, "%b<>%s+(%S+)%s(.*)")
if (arg==nil) then
s,e,cmd = strfind(data, "%b<>%s+(%S+)%s*")
end
if (cmd=="!itchat") then
user:SendPM(botname, "hi this is the it-chat room.begin chat now")
end
end
end
------------------------------------------------------------------------
end of code..

im trying to get the vipchat made by piglja the script godess =))
to popup in pm by a main command but now i can't get it to work...any ideas why?
and another thing the command is visible to all i would like it not to show others in mainchat

lynyrd

now i tried a different way..
but it still not works
is it close or way off?
please give me a little help

code:
------------------------------------------------------------------------
function DataArrival(user, data)
if (strsub(data, 1, 1) == "<") then
data=strsub(data,1,strlen(data)-1)  
s,e,cmd,arg = strfind(data, "%b<>%s+(%S+)%s(.*)")
if (cmd=="!itchat") then
if (whoTo == botname) then
if nick[user.sName] ~= nil then
nick[user.sName] = nil
SaveToFile(user.sName,fname,nick)
PmToAStupidTablesGrrrButIAmStartingToLikeThemLOL(msg,from,user.sName)
nick[user.sName]=user.sName
SaveToFile(user.sName,fname,nick)
return 1
else
user:SendPM(botname,"Du har inte tilltr?de till detta rum!!!")
end
end
end
------------------------------------------------------------------------

lynyrd

ok i give up on that one...i've tried alot of ways but no..
but not giving up.
got another idea =) how do i call a bot from this script?
it is a noob cut n paste job
code:
------------------------------------------------------------------------
Bot = "chatcontrol"
chatbotname = "ITGR" --the bot im trying to call

function Main()
   frmHub:UnregBot(botname)
   
end

function DataArrival(user,data)
if (strsub(data, 1, 1) == "<") then
data = strsub(data,1,strlen(data)-1)
s,e,cmd,arg = strfind(data, "%b<>%s+(%S+)%s(.*)")
if (arg==nil) then
s,e,cmd = strfind(data, "%b<>%s+(%S+)%s*")
end
if (cmd=="+it") then
user:SendPM(chatbotname,"test")
end
end
end
------------------------------------------------------------------------
my problem is that i have different intrest groups on my hub.so i made them chatrooms so they can chat privately..it's about 4 of those chatrooms..i dont want them to show in the list,and unreg them is a bad idea since no one can acsess them then. so i try to make a script so that you only need to type a command in main to acsess the chatroom..please please help me out

lynyrd

Hi after much headake and bad language i got a bit further.dispite my limited knowledge in both english and lua =)

code:
------------------------------------------------------------------------
BotName = "Chatkontroll"

Bot1 = "FFGR"

Bot2 = "ITGR"

cmd1 = "+ff"

cmd2 = "+it"

function Main()
frmHub:UnregBot(BotName)
end

function DataArrival(user,data)
if (strsub(data, 1, 1) == "<") then
data = strsub(data,1,strlen(data)-1)
s,e,cmd,arg = strfind(data, "%b<>%s+(%S+)%s(.*)")
if (arg==nil) then
s,e,cmd = strfind(data, "%b<>%s+(%S+)%s*")
end
if cmd == cmd1 then
user:SendPM(Bot1,"Hi this is the FFGR-ChatRoom...")
return 1
elseif cmd == cmd2 then
user:SendPM(Bot2,"hi this is the ITGR-chatroom...")
end
end
end
------------------------------------------------------------------------
end of code

now my only problems is that when i unreg the chat rooms they go offline. can any nice scripter give me a little hint?
and one more thing..how do i make the command invisible to others in mainchat? so they dont see "!ff"
have a nice day =)

Stravides

#6
QuoteOriginally posted by lynyrd
Hi after much headake and bad language i got a bit further.dispite my limited knowledge in both english and lua =)

------------------------------------------------------------------------
BotName = "Chatkontroll"

Bot1 = "FFGR"
Bot2 = "ITGR"
cmd1 = "!ff"	-- decide on your prefix
cmd2 = "!it"	-- double dash enables you to put a comment in..

function Main() 
	frmHub:UnregBot(BotName)  	-- This Unregisters the bot u sure u want to do this ? 	
--	frmHub:RegBot(BotName) 		-- is the opposite, but is not active as there is a -- in front of it.
end 

function DataArrival(user,data) 
	if (strsub(data, 1, 1) == "<") then 
		data = strsub(data,1,strlen(data)-1) 
		s,e,cmd,arg = strfind(data, "%b<>%s+(%S+)%s(.*)") 
		if (arg==nil) then 
			s,e,cmd = strfind(data, "%b<>%s+(%S+)%s*") 
		end 
		if cmd == cmd1 then
			user:SendPM(Bot1,"Hi this is the FFGR-ChatRoom...")
			return 1
		elseif cmd == cmd2 then
			user:SendPM(Bot2,"hi this is the ITGR-chatroom...")
			return 1 -- this means dont show it
		end 
	end
end
------------------------------------------------------------------------
now my only problems is that when i unreg the chat rooms they go offline. can any nice scripter give me a little hint?
and one more thing..how do i make the command invisible to others in mainchat? so they dont see "!ff"
have a nice day =)

They see !ff as you are using command +ff, change it as above...
also try to indent your code ie after an If or While indent, then close it as you end or else them, makes debugging easier too..
The return 1 will not show the command, but you must use the correct prefix (! or +)
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

lynyrd

hi,
is there any problem by not reg the bot?
it seems to work fine..
and the !ff thing was a mistype when i posted..sorry!
when looking at your "tutorial" i hit's me that every script should have it..
because i did'nt know what it excactly did and so on..
that would really help others to become better at scripting.
and for the unregged bot i read that it was'nt possible
off to new tasks for more headakes =)
many thanks stravides

Stravides

#8
basically the Regbot puts the bot in your userlists and can then send and receive PM's in a separate window.
otherwise the bot will be considered "offline" and the main chat window will give Private Message from xyz message..

Unregbot just takes it out of that listing...  all depends upon what you wanna achieve :)

I was just making sure that you knew the diff between reg n unreg, I tend to do both to make sure that its a clean install of the bot..
Unreg then Reg, but not neccessary  :D

Keep up the coding its the only way we'll improve :)
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

OpiumVolage

PmToAStupidTablesGrrrButIAmStartingToLikeThemLOL(msg,from,user.sName)

Hmmm, Piglja's coding style ;))

lynyrd

those were the good old days =)
her vipchat script is surely the best ever made

SMF spam blocked by CleanTalk