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?
December 04, 2008, 03:20:36 PM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Module Requests > Topic: A Topic Command
Pages: [1]   Go Down
« previous next »
Print
Author Topic: A Topic Command  (Read 600 times)
0 Members and 1 Guest are viewing this topic.
Jmrxxx
Freshman
*
Offline Offline

Posts: 1


A Topic Command
« on: August 18, 2005, 02:32:46 PM »

I was thinking it would be nice to have a !topic or !settopic command so that when someone sends a tell to the bot they can see whattheyare joining in on. Also this way when someone from inside the chat does an !invite <player> when the bot invites them, it will also show them the topic?

Unless I am miissing this.. I dont believe one exists Smiley
Logged
Derroylo
Rookie
**
Offline Offline

Posts: 43



A Topic Command
« Reply #1 on: August 22, 2005, 07:19:44 AM »

Well i have one but it isnīt compatible with the normal bebot Sad
Logged

Derroylo 220/23 NT RK2
Zacix
Rookie
**
Offline Offline

Posts: 72


A Topic Command
« Reply #2 on: August 22, 2005, 08:47:25 AM »

This topicmodule works ONLY if you have followed my guide for upgrading to a PHP5 and raidbot *clicky*. Although, shouldn't be too hard to change the code so it works for PHP4.

Code:
<?php

require_once&#40;"./includes/_colors.php"&#41;;

$topic = new Topic&#40;$bot&#41;;


$commands["tell"&#93;["topic"&#93; = &$topic;
$commands["tell"&#93;["cleartopic"&#93; = &$topic;
$commands["pgmsg"&#93;["topic"&#93; = &$topic;
$commands["pgjoin"&#93;[&#93; = &$topic;

class Topic&#123;
  
private $bot;
  private 
$topic;
  private 
$time;
  private 
$name;

  public function 
Topic&#40;&$bot&#41; &#123;
    
$this->bot = &$bot;
    
$this->topic = "";
    
$this->time = gmmktime&#40;&#41;;
    
$this->name = "";
  &
#125;
  
  
public function tell&#40;$name,$msg&#41; &#123;
    
$msg = explode&#40;" ",$msg&#41;;
    
if&#40;strtolower&#40;$msg[0&#93;&#41; == "!topic"&#41; &#123;
      
if&#40;$msg[1&#93; != ""&#41; &#123;
        
$this->topic = implode&#40;" ",array_slice&#40;$msg,1&#41;&#41;;
        
$this->time = gmmktime&#40;&#41;;
        
$this->name = $name;
        
$this->bot->aoc->send_tell&#40;$name,Infotext&#40;"New topic set."&#41;&#41;;
      
&#125;
      
else &#123;
        
if&#40;$this->topic != ""&#41; &#123;
          
$this->bot->aoc->send_tell&#40;$name,Infotext&#40;$this->topic . " [" . Highlight&#40;date&#40;"Y-M-d H&#58;i",$this->time&#41;&#41; . " GMT&#93;." . "Set by [" . Highlight&#40;$this->name&#41; . "&#93;"&#41;&#41;;
        
&#125;
        
else &#123;
          
$this->bot->aoc->send_tell&#40;$name,Infotext&#40;"No topic since [" . Highlight&#40;date&#40;"Y-M-d H&#58;i",$this->time&#41;&#41; . " GMT&#93;"&#41;&#41;;
        
&#125;
      
&#125;
    
&#125;
    
else if&#40;strtolower&#40;$msg[0&#93;&#41; == "!cleartopic"&#41; &#123;
      
$this->topic = "";
      
$this->time = gmmktime&#40;&#41;;
      
$this->bot->aoc->send_tell&#40;$name,Infotext&#40;"Topic is cleared"&#41;&#41;;
    
&#125;
  
&#125;
  
  
public function pgmsg&#40;$name, $msg&#41; &#123;
    
if&#40;$this->topic != ""&#41; &#123;
      
$this->bot->send_pgroup&#40;Infotext&#40;$this->topic . " [" . Highlight&#40;date&#40;"Y-M-d H&#58;i",$this->time&#41;&#41; . " GMT&#93;." . "Set by [" . Highlight&#40;$this->name&#41; . "&#93;"&#41;&#41;;
    
&#125;
    
else &#123;
      
$this->bot->send_pgroup&#40;Infotext&#40;"No topic since [" . Highlight&#40;date&#40;"Y-M-d H&#58;i",$this->time&#41;&#41; . " GMT&#93;"&#41;&#41;;
    
&#125;
  
&#125;
  
  
public function pgjoin&#40;$name&#41; &#123;
    
if&#40;$this->topic != ""&#41; &#123;
      
$this->bot->aoc->send_tell&#40;$name,Infotext&#40;$this->topic . " [" . Highlight&#40;date&#40;"Y-M-d H&#58;i",$this->time&#41;&#41; . " GMT&#93;." . "Set by [" . Highlight&#40;$this->name&#41; . "&#93;"&#41;&#41;;
    
&#125;
    
else &#123;
      
$this->bot->aoc->send_tell&#40;$name,Infotext&#40;"No topic since [" . Highlight&#40;date&#40;"Y-M-d H&#58;i",$this->time&#41;&#41; . " GMT&#93;"&#41;&#41;;
    
&#125;
  
&#125;
&#125;
[/url]
Logged

Zacix
Current projects:
RINGBot, BeBot branch
Neutnet, RK2 Neutral massmessage network
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1088


A Topic Command
« Reply #3 on: September 06, 2005, 04:06:50 AM »

Here my topic module - which should work with the unmodified bot.

There is no check for access rights in any of those functions though, so everybody can change the topic.

Code:
<?php
/*
* Topic Module for BE Bot <http&#58;//bebot.fieses.net>
* Module coded by Alreadythere
*/


  // add the default settings, if not existing
  
$db -> query&#40;"INSERT IGNORE INTO settings &#40;setting, value&#41; VALUES &#40;'topic', ''&#41;"&#41;;
  
$db -> query&#40;"INSERT IGNORE INTO settings &#40;setting, value&#41; VALUES &#40;'topictime', '0'&#41;"&#41;;
  
$db -> query&#40;"INSERT IGNORE INTO settings &#40;setting, value&#41; VALUES &#40;'topic_setter', ''&#41;"&#41;;




$topic = new Topic&#40;$bot&#41;;

$commands["pgjoin"&#93;[&#93; = &$topic;
$commands["pgmsg"&#93;["edittopic"&#93; = &$topic;
$commands["pgmsg"&#93;["topic"&#93; = &$topic;
$commands["tell"&#93;["edittopic"&#93; = &$topic;
$commands["tell"&#93;["topic"&#93; = &$topic;

/*
The Class itself...
*/
class Topic
&#123;
var $bot;


/*
Constructor&#58;
Hands over a referance to the "Bot" class.
*/
function Topic &#40;&$bot&#41;
&#123;
$this -> bot = &$bot;
$this -> topic = $this -> get_setting&#40;"topic"&#41;;
$this -> topictime = $this -> get_setting&#40;"topictime"&#41;;
$this -> topicsetter = $this -> get_setting&#40;"topic_setter"&#41;;
&#125;

function get_setting&#40;$set&#41;
&#123;
$res = $this -> bot -> db -> select&#40;"SELECT * FROM settings WHERE setting = '" . $set . "'"&#41;;

if &#40;!empty&#40;$res&#41;&#41;
return $res[0&#93;[1&#93;;
else
return "";
&#125;

function set_setting&#40;$set, $value&#41;
&#123;
$this -> bot -> db -> query&#40;"UPDATE settings SET value = '" . $value . "' WHERE setting = '" . $set . "'"&#41;;
&#125;

/*
This gets called on a tell with the command
*/
function tell&#40;$name, $msg&#41;
&#123;
if &#40;preg_match&#40;"/^" . $this -> bot -> commpre . "topic/i", $msg&#41;&#41;
$this -> bot -> send_tell&#40;$name, $this -> get_topic&#40;&#41;&#41;;
else if &#40;preg_match&#40;"/^" . $this -> bot -> commpre . "edittopic$/i", $msg, $info&#41;&#41;
$this -> set_topic&#40;$name, ""&#41;;
else if &#40;preg_match&#40;"/^" . $this -> bot -> commpre . "edittopic &#40;.+&#41;$/i", $msg, $info&#41;&#41;
$this -> set_topic&#40;$name, $info[1&#93;&#41;;
else
$this -> bot -> send_help&#40;$name&#41;;
&#125;

/*
This gets called on msg in the privategroup with the command
*/
function pgmsg&#40;$name, $msg&#41;
&#123;
if &#40;preg_match&#40;"/^" . $this -> bot -> commpre . "topic/i", $msg&#41;&#41;
$this -> bot -> send_pgroup&#40;$this -> get_topic&#40;&#41;&#41;;
else if &#40;preg_match&#40;"/^" . $this -> bot -> commpre . "edittopic$/i", $msg, $info&#41;&#41;
$this -> set_topic&#40;$name, ""&#41;;
else if &#40;preg_match&#40;"/^" . $this -> bot -> commpre . "edittopic &#40;.+&#41;$/i", $msg, $info&#41;&#41;
$this -> set_topic&#40;$name, $info[1&#93;&#41;;
&#125;

/* This function gets called when someone joins the group */
function pgjoin&#40;$name&#41; &#123;
$this -> bot -> send_tell&#40;$name, $this -> get_topic&#40;&#41;&#41;;
&#125;

/* Makes the time string readable */
function make_time&#40;&#41;
&#123;
$diftime = time&#40;&#41; - $this -> topictime;
$timestr = ' ';
$diftime = floor&#40;$diftime / 60&#41;;
$timestr .= $diftime % 60 . "min";
$diftime = floor&#40;$diftime / 60&#41;;
if &#40;$diftime > 0&#41;
$timestr = $diftime . "h" . $timestr;
return $timestr . " ago";
&#125;

function get_topic&#40;&#41;
&#123;
$topicstr = "";

if &#40;$this -> topic == ''&#41;
$topicstr .= "No topic!";
else
&#123;
$topicstr .= $this -> topic . " [set by " . $this -> topicsetter . " ";
$topicstr .= $this -> make_time&#40;&#41; . "&#93;"; 
&#125;

return $topicstr;
&#125;

function set_topic&#40;$name, $topic&#41;
&#123;
$this -> topictime = time&#40;&#41;;
$this -> topic = $topic;
$this -> topicsetter = $name;

$this -> set_setting&#40;"topic", $topic&#41;;
$this -> set_setting&#40;"topictime", $this -> topictime&#41;;
$this -> set_setting&#40;"topic_setter", $name&#41;;

$this -> bot -> send_pgroup&#40;"New topic&#58; " . $this -> get_topic&#40;&#41;&#41;;
&#125;
&#125;
?>
Logged
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1088


A Topic Command
« Reply #4 on: October 21, 2005, 06:21:26 PM »

Had an error in the script, corrected.
Logged
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1088


A Topic Command
« Reply #5 on: October 22, 2005, 02:40:37 AM »

One more error corrected...
Logged
Pages: [1]   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Module Requests > Topic: A Topic Command
« previous next »
 
Jump to:  

Recent
online not working after ...
by clashbot
[Today at 03:06:06 PM]

Bot not working after tod...
by Alreadythere
[Today at 01:04:41 PM]

Tokens Calulator
by Temar
[December 03, 2008, 01:09:03 PM]

Bebot does not work with ...
by IKShadow
[December 03, 2008, 08:54:04 AM]

!items database
by Temar
[December 03, 2008, 07:27:59 AM]

massive_pvp_time_table 1
by Sudoka
[December 03, 2008, 06:49:07 AM]

Log playtime from buddys ...
by IKShadow
[December 02, 2008, 06:48:12 AM]

[request] Raid timers
by Elesar1
[December 01, 2008, 04:41:09 PM]

Shared DB online list
by Temar
[December 01, 2008, 01:55:47 AM]

relay colors
by Temar
[December 01, 2008, 01:54:56 AM]
Stats
Members
Total Members: 1246
Latest: Vingus
Stats
Total Posts: 11191
Total Topics: 1508
Online Today: 21
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 6
Guests: 18
Total: 24
Vingus
clashbot
vikor
Stealth
Temar
scape

Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc | NewDef design by Bloc
Page created in 0.723 seconds with 28 queries. (Pretty URLs adds 0.033s, 4q)
Loading...