Mathzx / zxLoLBoT

An easy to use python 3 framework for writing league of legends chat bots using the xmpp protocol.
MIT License
14 stars 0 forks source link

Question: Command on Group Chat #1

Closed robotrono closed 10 years ago

robotrono commented 10 years ago

this is possible?

On a group chat send a command and send me the info

sorry for my bad english

Mathzx commented 10 years ago

What info do you want to get after sending a command?

robotrono commented 10 years ago

idk, for example a "Hello World", but i want send on a group chat

Mathzx commented 10 years ago

Yes you can use commands in group chat(rooms) using join_muc_room and leave_muc_room to join or leave rooms. Commands are created the same way as you would create them for individual chat.

robotrono commented 10 years ago

can you make a example please? i want send a message to room

http://puu.sh/9pLCW/e03d4bcc22.jpg

Mathzx commented 10 years ago
import zxlolbot

class testbot(zxlolbot.zxLoLBoT):
    """Small bot that joins the room 'test' and replies to the command 'hello' """
    def __init__(self, username, password, region="NA"):
        zxlolbot.zxLoLBoT.__init__(self, username, password, region)

        self.add_event_handler("got_online", self.got_online) #Adds an event handler for when the bot is online

    def got_online(self):
        """When the bot is online we can join the room"""
        self.join_muc_room("test")

    @zxlolbot.botcommand
    def hello(self, sender, args):
        """Replies hello"""
        self.message(sender, "Hello world :)")

bot = testbot("USERNAME", "PASSWORD", "REGION")
bot.connect()

The bot connects then joins the room test. At that point you can use the command hello in the test room or individually to get the reply

robotrono commented 10 years ago

Thanks for the example, but dont work the command on room chat, works fine individually chat.

Mathzx commented 10 years ago

Does the bot actually join the room? is it a private room or a public room? Are you on NA?

robotrono commented 10 years ago

yes the bot join to public room*, im in LAN Server

http://puu.sh/9qVDc/46ccc72574.jpg

robotrono commented 10 years ago

this is my code:

` import zxlolbot class helloworld(zxlolbot.zxLoLBoT): def init(self, username, password, region="LAN"): zxlolbot.zxLoLBoT.init(self, username, password, region) self.add_event_handler("message", self.on_message) self.add_event_handler("got_online", self.got_online) #Adds an event handler for when the bot is online def got_online(self): """When the bot is online we can join the room""" self.join_muc_room("eslolnet") def onmessage(self, args): """Handler for message event""" print(args["sender"] + ": " + args["message"]) @zxlolbot.botcommand def hello(self, sender, args): """Replies hello to the sender""" self.message(sender, "Hello world") @zxlolbot.botcommand def test(self, sender, args): """Handler for message event""" self.message(sender, "mierda") bot = helloworld("*****", "_") bot.connect() bot.set_status(level=30, status_msg="Version 1.0")

Mathzx commented 10 years ago

Did you edit zxlolbot.py yourself? If so can you show me what you changed in it? You can either mail me the full file to ContactMathzx@gmail.com or post it here (please use the python markdown)

Could you also tell me the content of the file called lol.properties in your league of legends folder?

It is located at

League of Legends\RADS\projects\lol_air_client\releases\(take the highest number here)\deploy

For example my own is located at:

C:\League of Legends\RADS\projects\lol_air_client\releases\0.0.1.94\deploy

Thank you

robotrono commented 10 years ago

Done, check your email.

Mathzx commented 10 years ago

Your bot account has to be level 5 in order to talk in group chats. I'm sorry for not thinking about that earlier!

robotrono commented 10 years ago

Oh thanks!

one question, Your bot have a timer feature for Baron and Dragon, how can implement that?