L
R
HOME
FORUM
DOWNLOADS
Content
Links
Browse SVN
SVN Commit log
Documentation (Wiki)
Developers
Taskmanager
User
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
November 22, 2008, 01:36:40 PM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search
Advanced search
BeBot - An Anarchy Online/Age Of Conan chat automaton
>
Forum
>
Development
>
Module Requests
> Topic:
!history - IGN style
Pages: [
1
]
Go Down
« previous
next »
Print
Author
Topic: !history - IGN style (Read 1267 times)
0 Members and 1 Guest are viewing this topic.
Zakus
Freshman
Offline
Posts: 18
!history - IGN style
«
on:
March 14, 2006, 04:56:09 PM »
Description:
A module that returns character history retrieved from auno.org in a robust format (similar in functionality to the IGN 'aunobio.php' plugin.
Commands:
!history (Can be used in tells, privategroup and guildchat)
Returns a single page of the parsed results of a lookup to auno.org, including Date, Level, AI Level, Faction, Guild (and rank)
I really found the way that the IGN bot returned info via their !history command to be nicely formatted and useful.
The one by Foxferal, while useful, was lacking in formatting.
My PHP kung fu is nearly non-existant but If nobody picks this up I'll be forced to do something ugly and probably poorly working.
Thanks in advance!
-Zakus
Logged
Zakus
Freshman
Offline
Posts: 18
Re: !history - IGN style
«
Reply #1 on:
March 14, 2006, 07:07:20 PM »
I've made some progress, but what I would like to do is call the 'whois' function from the whois module, and take apart what results.
If I can ask this in a way to not make php developers want to kill me:
It looks like I want to do something like:
Code:
$this -> whois -> whois($word2);
I could be competely off my rocker, but does that look like I'm headed in the correct direction?
-Z
Logged
Naturalistic
BeBot Contributor
Experienced
Offline
Posts: 221
Re: !history - IGN style
«
Reply #2 on:
March 14, 2006, 07:24:03 PM »
I believe it would be more like $this -> bot -> whois -> whois($name)
But I don't know how you set it up as, nor what you changed etc
But generally that's what I used when calling external functions.
Logged
220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php
Zakus
Freshman
Offline
Posts: 18
Re: !history - IGN style
«
Reply #3 on:
March 14, 2006, 07:27:56 PM »
I'd be scary if I knew what I was doing.
Thanks for the referral, I'm going to keep hammering on this.
I actually fixed a problem with the logic that was used in the old IGN plugin. Go me.
Logged
Xenixa
BeBot Contributor
Expert
Offline
Posts: 307
Re: !history - IGN style
«
Reply #4 on:
March 14, 2006, 07:30:37 PM »
If you're talking about Alreadythere's whois cache module use this:
Code:
$who = $this -> bot -> whois -> lookup($name);
You can find the lookup() function in the WhoisCache.php file to see what it will return and then format as you please.
Logged
<<< Hack's in
Zend Studio
All my Custom Bebot files may be
Found Here
<-clicky
Zakus
Freshman
Offline
Posts: 18
Re: !history - IGN style
«
Reply #5 on:
March 14, 2006, 07:32:09 PM »
That may be exactly what I was looking for.
Thanks much.
-Z
Logged
Zakus
Freshman
Offline
Posts: 18
Re: !history - IGN style
«
Reply #6 on:
March 14, 2006, 07:43:59 PM »
Well, that wasn't the module I was using afterall, but it gave me some examples to play with tomorrow.
In case anyone cares, here is what I'm messing with at this point:
--Edited to reflect new changes 03/15/2006--
Code:
<?php
/*
* History.php - Online plugin to display user history
*
* BeBot - An Anarchy Online Chat Automaton
* Copyright (C) 2004 Jonas Jax
* Developed by Blondengy (RK1)
* Special thanks goes out to Khalem (RK1) for his support.
*
* History.php written by Foxferal (RK1), concept borrowed from IGN Networks
* Hacked to look more like the IGN aunobio module, using ugly code theft, by Zakus - RK1 03/15/2006
*/
$history
= new
History
(
$bot
);
$commands
[
"tell"
][
"history"
] = &
$history
;
$commands
[
"pgmsg"
][
"history"
] = &
$history
;
$commands
[
"gc"
][
"history"
] = &
$history
;
/*
The Class itself...
*/
class
History
{
var
$fname
;
var
$lname
;
var
$orgname
;
/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function
History
(&
$bot
)
{
$this
->
bot
= &
$bot
;
}
/*
This gets called on a tell with the command
*/
function
tell
(
$name
,
$msg
)
{
preg_match
(
"/^"
.
$this
->
bot
->
commpre
.
"history (.+)$/i"
,
$msg
,
$info
);
$info
[
1
] =
ucfirst
(
strtolower
(
$info
[
1
]));
if (
$this
->
bot
->
aoc
->
get_uid
(
$info
[
1
]))
$this
->
bot
->
send_tell
(
$name
,
$this
->
player_history
(
$info
[
1
]));
else
$this
->
bot
->
send_tell
(
$name
,
"Player <font color=#ffff00>"
.
$info
[
1
] .
"</font> does not exist."
);
}
/*
This gets called on a msg in the privgroup with the command
*/
function
pgmsg
(
$name
,
$msg
)
{
preg_match
(
"/^"
.
$this
->
bot
->
commpre
.
"history (.+)$/i"
,
$msg
,
$info
);
$info
[
1
] =
ucfirst
(
strtolower
(
$info
[
1
]));
if (
$this
->
bot
->
aoc
->
get_uid
(
$info
[
1
]))
$this
->
bot
->
send_pgroup
(
$this
->
player_history
(
$info
[
1
]));
else
$this
->
bot
->
send_pgroup
(
"Player <font color=#ffff00>"
.
$info
[
1
] .
"</font> does not exist."
);
}
/*
This gets called on a msg in the guildchat with the command
*/
function
gc
(
$name
,
$msg
)
{
preg_match
(
"/^"
.
$this
->
bot
->
commpre
.
"history (.+)$/i"
,
$msg
,
$info
);
$info
[
1
] =
ucfirst
(
strtolower
(
$info
[
1
]));
if (
$this
->
bot
->
aoc
->
get_uid
(
$info
[
1
]))
$this
->
bot
->
send_gc
(
$this
->
player_history
(
$info
[
1
]));
else
$this
->
bot
->
send_gc
(
"Player <font color=#ffff00>"
.
$info
[
1
] .
"</font> does not exist."
);
}
/*
Get info on player
*/
function
player_history
(
$name
)
{
$reply
= (
" No data found for (ucword2) "
);
$newurl
=
"http://auno.org/ao/char.php?output=xml&dimension="
.
$this
->
bot
->
dimension
.
"&name="
.
$name
;
$data
=
file_get_contents
(
$newurl
);
if (!
stristr
(
$data
,
"no character found"
) && !empty(
$data
)) {
preg_match_all
(
'|<entry date="(.*)" level="(.*)" ailevel="(.*)" faction="(.*)" guild="(.*)" rank="(.*)" />|Ui'
,
$data
,
$matches
);
$who
=
$this
->
bot
->
whois
->
lookup
(
$name
);
$blob
.=
"<font color=CCInfoHeadline>Character History For: \n</font>"
;
$blob
.=
"<font color=CCInfoHeadline>::: "
.
$who
[
'firstname'
].
" \"$name\" "
.
$who
[
'lastname'
].
" :::</font>\n\n"
;
$blob
.=
":: Level/AL: <font color=CCCCTextColor>"
.
$who
[
'level'
].
" / <font color=#33FF33>"
.
$who
[
'at_name'
].
"("
.
$who
[
'at'
].
")</font></font>\n"
;
$blob
.=
":: Breed: <font color=CCCCTextColor>"
.
$who
[
'breed'
].
"</font>\n"
;
$blob
.=
":: Gender: <font color=CCCCTextColor>"
.
$who
[
'gender'
].
"</font>\n"
;
$blob
.=
":: Profession: <font color=CCCCTextColor>"
.
$who
[
'profession'
].
"</font>\n"
;
$blob
.=
":: Current Org: <font color=CCCCTextColor>"
.
$who
[
'org'
].
"</font>\n"
;
$blob
.=
":: Org Rank: <font color=CCCCTextColor>"
.
$who
[
'rank'
].
"</font>\n\n"
;
$blob
.=
"<font color=CCInfoHeader>Date Level AI Faction Org. and (Rank)</font>\n"
;
$blob
.=
"ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ\n"
;
for(
$i
=
0
;
$i
<
count
(
$matches
[
0
]);
$i
++) {
if(
strlen
(
$matches
[
2
][
$i
])==
1
){
$matches
[
2
][
$i
]=
"00"
.
$matches
[
2
][
$i
];}
if(
strlen
(
$matches
[
2
][
$i
])==
2
){
$matches
[
2
][
$i
]=
"0"
.
$matches
[
2
][
$i
];}
if(
strlen
(
$matches
[
3
][
$i
])==
1
){
$matches
[
3
][
$i
]=
"0"
.
$matches
[
3
][
$i
];}
if(empty(
$matches
[
3
][
$i
])){
$matches
[
3
][
$i
]=
" "
;}
if(
$matches
[
4
][
$i
]==
"Omni"
){
$matches
[
4
][
$i
] .=
" "
;}
if(
$matches
[
4
][
$i
]==
"Clan"
){
$matches
[
4
][
$i
] .=
" "
;}
$blob
.=
"<font color=#ffffff>"
.
$matches
[
1
][
$i
].
"</font> | "
;
$blob
.=
"<font color=CCInfoHeader>"
.
$matches
[
2
][
$i
].
"</font> | "
;
$blob
.=
"<font color=CCInfoText>"
.
$matches
[
3
][
$i
].
"</font> | "
;
$blob
.=
"<font color=#ffffff>"
.
$matches
[
4
][
$i
].
"</font> | "
;
if(!empty(
$matches
[
5
][
$i
]))
{
$blob
.=
"<font color=CCInfoHeadline>"
.
$matches
[
5
][
$i
].
" ("
.
$matches
[
6
][
$i
].
")</font>\n"
;
}
else {
$blob
.=
"Not in Guild\n"
;}
}
return
"History for "
.
$name
.
" :: "
.
$this
->
bot
->
make_blob
(
"click to view"
,
$blob
);
}
else
{
return
"No name specified."
;
}
}
}
?>
«
Last Edit: March 15, 2006, 04:41:27 PM by Zakus
»
Logged
Xenixa
BeBot Contributor
Expert
Offline
Posts: 307
Re: !history - IGN style
«
Reply #7 on:
March 14, 2006, 08:23:25 PM »
I don't recall what IGN's History format looks like exactly. But if it looks like what I did with the alts.php for Bebot that would be nifty. You can find an example of what it looks like here:
http://bebot.shadow-realm.org/index.php/topic,204.msg1641.html#msg1641
And the code for formating it that way is here:
http://bebot.shadow-realm.org/index.php/topic,288.msg1761.html#msg1761
You could use the whois info for the header area then call the History to parse under that.
Logged
<<< Hack's in
Zend Studio
All my Custom Bebot files may be
Found Here
<-clicky
Khalem
BeBot Founder
Administrator
Grandmaster
Offline
Gender:
Posts: 670
Re: !history - IGN style
«
Reply #8 on:
March 15, 2006, 11:44:20 AM »
Foxferals History module based on IGN (I dislike the layout)
Code:
<?php
/*
* History.php - Online plugin to display user history
*
* BeBot - An Anarchy Online Chat Automaton
* Copyright (C) 2004 Jonas Jax
* Developed by Blondengy (RK1)
* Special thanks goes out to Khalem (RK1) for his support.
*
* History.php written by Foxferal (RK1), concept borrowed from IGN Networks
*/
$history
= new
History
(
$bot
);
$commands
[
"tell"
][
"history"
] = &
$history
;
$commands
[
"pgmsg"
][
"history"
] = &
$history
;
$commands
[
"gc"
][
"history"
] = &
$history
;
/*
The Class itself...
*/
class
History
{
var
$bot
;
/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function
History
(&
$bot
)
{
$this
->
bot
= &
$bot
;
}
/*
This gets called on a tell with the command
*/
function
tell
(
$name
,
$msg
)
{
preg_match
(
"/^"
.
$this
->
bot
->
commpre
.
"history (.+)$/i"
,
$msg
,
$info
);
$info
[
1
] =
ucfirst
(
strtolower
(
$info
[
1
]));
if (
$this
->
bot
->
aoc
->
get_uid
(
$info
[
1
]))
$this
->
bot
->
send_tell
(
$name
,
$this
->
player_history
(
$info
[
1
]));
else
$this
->
bot
->
send_tell
(
$name
,
"Player <font color=#ffff00>"
.
$info
[
1
] .
"</font> does not exist."
);
}
/*
This gets called on a msg in the privgroup with the command
*/
function
pgmsg
(
$name
,
$msg
)
{
preg_match
(
"/^"
.
$this
->
bot
->
commpre
.
"history (.+)$/i"
,
$msg
,
$info
);
$info
[
1
] =
ucfirst
(
strtolower
(
$info
[
1
]));
if (
$this
->
bot
->
aoc
->
get_uid
(
$info
[
1
]))
$this
->
bot
->
send_pgroup
(
$this
->
player_history
(
$info
[
1
]));
else
$this
->
bot
->
send_pgroup
(
"Player <font color=#ffff00>"
.
$info
[
1
] .
"</font> does not exist."
);
}
/*
This gets called on a msg in the guildchat with the command
*/
function
gc
(
$name
,
$msg
)
{
preg_match
(
"/^"
.
$this
->
bot
->
commpre
.
"history (.+)$/i"
,
$msg
,
$info
);
$info
[
1
] =
ucfirst
(
strtolower
(
$info
[
1
]));
if (
$this
->
bot
->
aoc
->
get_uid
(
$info
[
1
]))
$this
->
bot
->
send_gc
(
$this
->
player_history
(
$info
[
1
]));
else
$this
->
bot
->
send_gc
(
"Player <font color=#ffff00>"
.
$info
[
1
] .
"</font> does not exist."
);
}
/*
Get info on player
*/
function
player_history
(
$name
)
{
if(
$name
!=
""
)
{
$result
=
""
;
$file
=
file
(
"http://auno.org/ao/char.php?dimension="
.
$this
->
bot
->
dimension
.
"&t=auno-print&name="
.
$name
.
" "
);
if(!
$file
) return
"Database is currently not reachable."
;
while (list (
$radnr
,
$rad
) =
each
(
$file
))
{
$result
.=
$rad
;
}
if(!
stristr
(
$result
,
"no character found"
))
{
$result
=
preg_grep
(
'#^<td>200#'
,
explode
(
"\n"
,
$result
));
$ymera
.=
"<font color='CCInfoHeadline'>History for "
.
$name
.
"<br>"
;
foreach (
$result
as
$line
)
{
$result
=
str_replace
(
"</td>"
,
""
,
$line
);
$result
=
str_replace
(
"</tr>"
,
"<td>"
,
$result
);
$result
=
split
(
"<td>"
,
$result
);
if(empty(
$result
[
4
]))
{
$result
[
4
]=
"- Not in guild"
;
}
$ymera
.=
"<font color='CCInfoHeader'>• Date: </font><font color='CCInfoText'>"
.
$result
[
1
] .
"</font><font color='CCInfoHeader'> Level: </font><font color='CCInfoText'>"
.
$result
[
2
] .
"<br><font color='CCInfoText'>"
.
$result
[
5
].
" "
.
$result
[
4
].
" ("
.
$result
[
3
].
").</font>\n"
;
}
$ymera
.=
"<br><font color=CCInfoHeadline>Plugin by Foxferal\n\n"
;
}
else
{
$ymera
=
"Character not found"
;
}
return
"History for "
.
$name
.
" :: "
.
$this
->
bot
->
make_blob
(
"click to view"
,
$ymera
);
}
else
{
return
"No name specified."
;
}
}
}
?>
Logged
BeBot Founder and Fixer Kingpin
Madman coder and destroyer of good code
MatHack
Guest
Re: !history - IGN style
«
Reply #9 on:
March 15, 2006, 11:51:14 AM »
My version (layout looks very like IGN, simply because it has the best overview):
Code:
<?php
/*
* History.php - Online plugin to display user history
*
* BeBot - An Anarchy Online Chat Automaton
* Copyright (C) 2004 Jonas Jax
* Developed by Blondengy (RK1)
* Special thanks goes out to Khalem (RK1) for his support.
*
* History.php written by Foxferal (RK1), concept borrowed from IGN Networks
*/
$history
= new
History
(
$bot
);
$commands
[
"tell"
][
"history"
] = &
$history
;
$commands
[
"gc"
][
"history"
] = &
$history
;
class
History
{
var
$bot
;
function
History
(&
$bot
)
{
$this
->
bot
= &
$bot
;
}
function
tell
(
$name
,
$msg
)
{
preg_match
(
"/^"
.
$this
->
bot
->
commpre
.
"history (.+)$/i"
,
$msg
,
$info
);
$info
[
1
] =
ucfirst
(
strtolower
(
$info
[
1
]));
if (
$this
->
bot
->
aoc
->
get_uid
(
$info
[
1
]))
$this
->
bot
->
send_tell
(
$name
,
$this
->
player_history
(
$info
[
1
]));
else
$this
->
bot
->
send_tell
(
$name
,
"Character <font color=#ffff00>"
.
$info
[
1
] .
"</font> does not exist."
);
}
function
gc
(
$name
,
$msg
)
{
preg_match
(
"/^"
.
$this
->
bot