Info:
Simple solution for synchronization between PtokaX and AJAX Chat (https://blueimp.net/ajax/).
Requirements:
- AJAXChat (any version, as long as the ajax_chat_messages table have the same layout)
- luasql.mysql (http://www.keplerproject.org/luasql/index.html)
Installation:
First of all, edit settings inside the script, according to your needs. Then create file receivechat.id (the path to it described in the script) and write the last message id from AJAX Chat inside. If you're using new AJAX Chat then just write 1. If not - get the last message id by browsing the ajax_chat_messages table inside the AJAX Chat database.
Run the script from PtokaX. All should work, but don't forget to check /ptokax/logs/script.log for possible errors.
Notes:
- the script must be on top of any other scripts to work correctly, you can modify the order of scripts in the /cfg/scripts.xml file
- if you ban user from PtokaX - AJAX Chat will not perform ban-check until user's log-in. This is a default behavior in AJAX Chat and you probably can alter it easily by modding sources a little.
Known bugs:
- none
Version 2:
ajaxchatsync.lua (http://pastebin.com/Q1M3Dazk) - PtokaX <> AJAXChat sync
Version 1 (old and unsupported):
receivechat.lua (http://pastebin.com/VENmw7HE) - AJAX Chat to PtokaX
sendchat.lua (http://pastebin.com/NHVufqMr) - PtokaX to AJAX Chat
banchat.lua (http://pastebin.com/3CMsaQdU) - bans system
My reason is not working ..
Your reason... What?
I can't get what you mean.
small update for sendchat.lua:
- fixed bad chars detection :)
Hello, great script, but i have some Iconv problems:
- dc: ?rv?ztűrő t?k?rf?r?g?p
- chat: ?rv?zt?r? t?k?rf?r?g?p
The same backward:
- chat: ?rv?ztűrő t?k?rf?r?g?p
- dc: ??rv??zt??r?? t? 1/4 k??rf??r??g??p
And please ignore the commands eg. !startscript recievechat.lua
Can you help me?
I'm not sure, but it seems that you can disable iconv.
Try to set UseIconv = false
If that doesn't work - edit the IconvFrom/IconvTo variable to fit your codepage. I don't know what codepage is default on your hub, so i can't say what do you need exactly. Use iconv -l to get the list of all possible codepages.
As for the second question - the latest update fixes that problem. Download new sendchat.lua or just edit line 24:
if string.sub(chat,1,1) == v then
Command ignore is ok, but useiconv = false not :S
I tried another codepages but the result is not perfect
UseIconv = true
IconvFrom = "utf-8"
IconvTo = "cp1252//TRANSLIT"
ReplaceWhat = {"á","Ă?","Ă?","Ăł","Ă?","Ĺ?","Ăş","ĂĽ","Ĺ?","Ă?","Ă ","Ă?","Ă?","Ă?","Ăś","Ĺ?","%[b]","%[/b]","%[u]","%[/u]","%[i]","%[/i]",...}
ReplaceWith = { "?", "?", "?", "?", "?", "ő", "?", "?", "ű", "?", "?", "?", "?", "?", "?", "Ű", "", "", "", "", "", "", "", "", "", "" }
chat:?rv?ztűrő t?k?rf?r?g?p - ?RV?ZTŰRŐ T?K?RF?R?G?P
dc: ?rv?ztűrő t?k?rf?r?g?p - Ă?RVĂ?ZTŰRĹ? T?K?RF?R?G?P
It seems dc can't display some characters. I still would be nice, but sending doesn't work accented characters. Maybe with repleca.
I made some experiments and it seems that your codepage is latin2.
Try to use latin2 with and without the //TRANSLIT suffix.
I tried but i got empty messages if the original chat message contains any accented character.
Okay, can you upload a log file from your dc-client? Just enable main chat logging and get the output file with the original codepage.
I don't get what codepage is in use on your hub. According to wikipedia default codepage for hungarian language is latin2. ???
I found it. :)
Delete SET NAMES utf8;
from recievechat.lua line 67 and also sendchat.lua line 43.
thx
That's very strange.
Probably your AJAX Chat database uses codepage different from utf8?
No, database and tables are UTF-8 (my vps use utf8 codepage also)
Well, i'm glad that it works, but i can't figure out how ::)
Little change because of color codes
ReplaceWhat = { ...,"%[/color]","%[color=gray]","%[color=silver]","%[color=white]","%[color=yellow]","%[color=orange]","%[color=red]","%[color=fuchsia]","%[color=purple]","%[color=navy]","%[color=blue]","%[color=aqua]","%[color=teal]","%[color=green]","%[color=lime]","%[color=olive]","%[color=maroon]","%[color=black]",}
ReplaceWith = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",}
oh, yeah, i forgot about url and color
by the way, you're doing it wrong
just add:
"%[color.-]","%[/color]","%[url.-]","[/url]"
Thx
fix: "[/url]" >> "%[/url]"
and please fix the new line character from chat (shift+enter) to dc: \n
very future request:
userlist of dc >> ajax_chat_online table of chat
ajax_chat_online table >> bot to dc
I don't know yet how to translate new line codes to dc. Seems that \n or \r\n simply doesn't work the way it should.
I'll see what i can do when i'll have some free time.
Talking about user list synchronization - I don't think that this is a good idea.
If we will transport DC-users to AJAX Chat it'll be a pain in the ass :) For example - what about ajax chat private message feature? So we also need a private message transport and many other things besides of it...
The other way (chat > dc) is not too complex. I think i'll do something like that soon.
Simply disable pm in ajax chat ( $config['allowPrivateMessages'] = false; ) if i would like to use userlist (dc > chat) or a bot send the private messages to user in dc. :D
another update
sendchat.lua:
- added UseSetNames variable to settings
recievechat.lua:
- added UseSetNames variable to settings
- added replacement patterns for 'color' and 'url' bb-codes
- fixed new line characters
I also did some code management and added more informative version info.
Just to have an easy way to check whether your script updated or not :)
I started to write the userlist synchronization script but it's far from done.
Anyway, happy new year to everyone :)
why not windows version? :)
or you can make it work?
Quote from: SaymoN on 31 December, 2010, 11:06:49
why not windows version? :)
or you can make it work?
From what i see Ajax Chat is web based you should be able to use it on either Linux, MacOS or Linux as long as you have a Webserver running (for example Apache) so the OS you're running is irrelevant in that aspect. The scripts are for PtokaX so OS is irrelevant here as well as PtokaX uses the same scripts no matter which OS you are running.
Quote from: Psycho_Chihuahua on 31 December, 2010, 14:21:22
so the OS you're running is irrelevant in that aspect
I'm using some system binaries, so it isn't possible to run my srcipts without a little modification...
Well, it'll actually run but it'll not work :)
Quote from: SaymoN on 31 December, 2010, 11:06:49
why not windows version? :)
Because i have no servers running windows.
You can try to run it anyway. Just get a windows version of mysql client and iconv (http://gnuwin32.sourceforge.net/packages/libiconv.htm). Then make sure that paths to those binaries described in your system %PATH% variable. After that run script and check the error log for possible problems.
ok.
(19:51:35) ChatBot: Error: Connection status: 403
That's not about my scripts, check your AJAX Chat installation.
Basicaly the 403 error means that you don't have the access to some required files. Probably this is caused by the configuration of your web-server.
1.
I tried the private message in webchat (I never want to use it)
webchat:
(20:43:27) (test): (whispers to (test2)) pm_test_message
dc:
[20:43:27] <(test1)> /privmsgto (test2) pm_test_message
[20:43:27] <(test1)> /privmsg pm_test_message
2.1
Webchat:
(22:04:34) (test1): | test
dc:
[22:04:34] <(test1)>
[22:04:34] *** test
2.2
dc:
[22:03:49] <test2> | test
webchat:
(22:03:49) test2: & #124; test (without space after &)
fixed :)
sendchat.lua 1.0.2:
- fixed | and $ chars
receivechat.lua 1.0.4:
- fixed | char
- added workaround for AJAX Chat private messaging
Perfect job. :)
Thx
I'm glad to present the new version - 2.0.1 :)
- based on the luasql - no more system dependencies, text files and other mess
- one script for all
tested with PtokaX 0.4.1.2 (luasql-2.1.1) and 300+ users without any noticable problems
UPD: it seems that no one is interested in this, so i'll not bother anyone with updates anymore - links in the first post contain actual versions, always. PM me if you have problems.