◢███◤      ◢██◤                            ◢██◤                            
     ◢██◤       ◢██◤                            ◢██◤                             
    ◢██◤       ◢██◤                            ◢██◤                              
   ◢██◤       ◢██◤                            ◢██◤                               
  ◢██◤       ◢██◤                            ◢██◤                                
◢███◤       ◢██◤                            ◢██◤                          ◥██◣   
◥███       ◢█████◣    ◢████████◤ ◢███████◤ ◢██◤ ◢██◤                 ◢██◤   ██◣  
 ███      ◢███████◣        ◢██◤ ◢██◤ ◢██◤ ◢███████◤                 ◢██◤    ███  
 ███     ◢██◤  ◢██◤ ◢████████◤ ◢██◤      ◢█████◣                   ◢██◤     ███  
 ███    ◢██◤  ◢██◤ ◢██◤  ███◤ ◢██◤ ◢██◤ ◢██◤◥███◣                 ◢██◤      ███  
 ◥██   ◢██◤  ◢██◤ ◢████████◤ ◢███████◤ ◢██◤  ◥███◣               ◢██◤       ███◣ 
  ◥██◣                                                          ◢██◤       ◢███◤ 
                                 ◢███◤ ◢███◤ ◢██◤  ◢██◤ ◢█████████◤       ◢██◤   
                                ◢█████████◤ ◢██◤  ◢██◤ ◢██◤  ████◤       ◢██◤    
                               ◢██◤◢█◤◢██◤ ◢██◤  ◢██◤ ◢██◤   ███◤       ◢██◤     
                              ◢██◤   ◢██◤ ◢████████◤ ◢█████████◤       ◢██◤      
                             ◢██◤   ◢██◤ ◢████████◤ ◢█████████◤      ◢███◤       

0003
Python 3.x chat API
6af2q7
If you want to use python and hackmud's chat API then you can use this tutorial! The hackmud_chat library is the base of this tutorial so please check out chalios' github: `3https://github.com/chalios/hackmud_chat_py` Unfortunately it's written in python 2 so all of you who wants to use python 3 it wouldn't work. I'll also show you a quick example of doing a python script which sends a quick message in a specific channel. So the slightly rewritten hackmud chat API is available on my github: `3https://github.com/Wrench56/hackmud` As you can see, you need your chat_token which is a bit tricky to get. Here is a tutorial which will describe how to get a token and also how the chat API works: `3https://www.hackmud.com/forums/general_discussion/chat_api_documentation` Thanks for the tutorial mogery! After you get your token, you can start scripting in python. You need to download both hackmud.py and hackmud_chat.py from my github. 'utlis.py' is optional but I will use it in this tutorial. Also main.py is optional but I highly recommend you to use it as a start. Basically my scripts is made so that it could be run easily by linux crons. So each "advertise board" are separated in different scripts that can be run by different crons. If you don't want to use this system for some reason there is an example file in chalios' repo. So the following script does the main part: `5import` hackmud_chat `5import` os `5import` time `5import` datetime PATH = os.getcwd() `5def` `2debug`(msg): `5with` open(os.path.join(PATH, 'debug.log'), 'a', encoding='utf-8') `5as` file: now = datetime.datetime.now() time = now.strftime("[%Y-%m-%d %H:%M:%S]") file.write(time + ' - ' + str(msg) + '\n') file.close() `5def` `2send`(func): user, channel, msg = func() `5if` isinstance(channel, list): `5for` c in channel: user.say(c, msg) `5else`: user.say(channel, msg) `5def` `2init`(): acct = hackmud_chat.Account(token='YourToken') user = acct.get_user('YourUsername') `5return` acct, user You can see the script is built out of 3 functions: - The first is only a debug function (I pretty much just attached it to the script) - The second function: send is a decorator - The third one is the init which you will use at the start of your main script The second function is a bit interesting. You see it has an arg called func which will be the function in the main file. The function from the main file should return three objects: a user object, a channel and a message. The channel can be either a single string or a list of channels. Unfortunately you can't join chats with the chat API so you have to join them manually in hackmud. The main file looks like: `5from` utils `5import` debug, send, init acct, user = init() `3@send` `5def` `2test`(): `5return` user, "5P4M", "`2Pls` ignore this message!" As you can see, it's very short and you don't need to do much. There should be a function which is called by the decorator `3@send`. The function must also return the three objects I mentioned earlier: the user, the channel (or list of channels) and the message! The init is used to get the user and account. This is the program you need to write to make an advertisement :). Linux part: So to make a linux cron you need to edit the crontab. If you are not familiar with crons I recommend you reading this guide: `3https://www.adminschoice.com/crontab-quick-reference`. In order to edit the crontab you need to use: `0crontab -e` (-e is the arg for editing). Then you need to write your cron. My test_cron looked something like this: `00 * * * * python3 /home/user/hackmud/main.py` This runs the cron every 0th minutes of any hours. Of course, you need to change the path for your script but that's it. If this is done leave the editor and you are good to go :) I hope I could help you! Special thanks to: @dtr[-], @Fayti1703[slyware], @ghamb[+], @matr1x[%] and to @mogery@xc
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Very Epic! thx for sauce boss!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -