Jump to content

Recommended Posts

 

In my server, the system will pop up the following text when botting, asking for the calculation formula and answer. In order to solve this problem, I want to make a plugin, now I need to know how to get text information and text events. Can someone help me, please

 

 

image.thumb.png.36483e554ce2a1552bca7778c13352f9.png

Link to comment
https://wrobot.eu/forums/topic/11013-how-to-get-text-from-chanel%EF%BC%9F/
Share on other sites

If you use lua, you can try code like 

if DEFAULT_CHAT_FRAME then 
	local c=DEFAULT_CHAT_FRAME:GetNumMessages()
	for i=1,c do
		local msg = DEFAULT_CHAT_FRAME:GetMessageInfo(i)
		if msg then
			YOUR CODE HERE
		end
	end
end

If message are display in WRobot tab "Chat" you can also use wrobot class Channel (sample: https://wrobot.eu/forums/topic/4802-mage-portal-bot/ )

 

19 hours ago, Droidz said:

If you use lua, you can try code like 


if DEFAULT_CHAT_FRAME then 
	local c=DEFAULT_CHAT_FRAME:GetNumMessages()
	for i=1,c do
		local msg = DEFAULT_CHAT_FRAME:GetMessageInfo(i)
		if msg then
			YOUR CODE HERE
		end
	end
end

If message are display in WRobot tab "Chat" you can also use wrobot class Channel (sample: https://wrobot.eu/forums/topic/4802-mage-portal-bot/ )

 

My version of the game is 2.4.3. This statement does not work properly:DEFAULT_CHAT_FRAME:GetMessageInfo(i).I checked some plug-ins written by others.His solution is to make a wow plug-in. This event

"CHAT_MSG_SYSTEM" 

is used, and then the text is in arg1. How can wrobot extract arg1 to get the text?

19 hours ago, Droidz said:

If you use lua, you can try code like 


if DEFAULT_CHAT_FRAME then 
	local c=DEFAULT_CHAT_FRAME:GetNumMessages()
	for i=1,c do
		local msg = DEFAULT_CHAT_FRAME:GetMessageInfo(i)
		if msg then
			YOUR CODE HERE
		end
	end
end

If message are display in WRobot tab "Chat" you can also use wrobot class Channel (sample: https://wrobot.eu/forums/topic/4802-mage-portal-bot/ )

 

--[[     Options start here     ]]
local M="CHAT_MSG_SYSTEM" 

function MS(msg)
   SendChatMessage(msg)
end
function yz() 
	if (event==M) then 
local zj=string.find(arg1, "答题时间")
    if(zj) then
          end
local s1=arg1
local zj=string.find(s1, "+")
    if(zj) then
local s=arg1
local z="+"
local y="?="
local param1, param2 = string.find(s, z) 
local m = string.len(s) 
s=string.sub(s,param2+1)
local ts = string.reverse(s)
    local param1, param2 = string.find(ts, y) 
    local m = string.len(s) - param2 + 1   
    local hou
    if (y == false) then
    	hou = string.sub(s, m+1, string.len(s)) 
    else
    	hou = string.sub(s, 1-1, m-1) 
    end
local s=arg1
local z=":"
local y="+"
local param1, param2 = string.find(s, z) 
local m = string.len(s) 
s=string.sub(s,param2+1)
local ts = string.reverse(s)
    local param1, param2 = string.find(ts, y) 
    local m = string.len(s) - param2 + 1   
    local qian
    if (strchar == false) then
    	qian = string.sub(s, m+11, string.len(s))
    else
    	qian = string.sub(s, 1+10, m-1) 
    end
print(qian,"+",hou,"=",qian+hou) 
MS(tostring(qian+hou))




    else



local s=arg1
local z="-"
local y="?="
local param1, param2 = string.find(s, z) 
local m = string.len(s) 
s=string.sub(s,param2+1)
local ts = string.reverse(s)
    local param1, param2 = string.find(ts, y) 
    local m = string.len(s) - param2 + 1   
    local hou
    if (strchar == false) then
    	hou = string.sub(s, m+1, string.len(s)) 
    else
    	hou = string.sub(s, 1-1, m-1) 
    end
local s=arg1
local z=":"
local y="-"
local param1, param2 = string.find(s, z) 
local m = string.len(s) 
s=string.sub(s,param2+1)
local ts = string.reverse(s)
    local param1, param2 = string.find(ts, y) 
    local m = string.len(s) - param2 + 1   
    local qian
    if (strchar == false) then
    	qian = string.sub(s, m+10, string.len(s)) 
    else
    	qian = string.sub(s, 1+10, m-1) 
    end
print(qian,"-",hou,"=",qian-hou) 
MS(tostring(qian-hou))

    end
	end 
end 
local F=CreateFrame("Frame") 
F:SetScript("OnEvent",yz) 
F:RegisterEvent(M)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...