Anope IRC Services

Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: [Request] global_randquotes  (Read 7006 times)

0 Members and 1 Guest are viewing this topic.

Andrey

  • Anope User
  • Offline Offline
  • Gender: Male
  • Posts: 65
    • RedeNorte
[Request] global_randquotes
« on: September 19, 2008, 02:24:12 AM »

any can set options for choose send quote to prvmsg or notice?

for default only notice.
Logged

Andrey

  • Anope User
  • Offline Offline
  • Gender: Male
  • Posts: 65
    • RedeNorte
Re: [Request] global_randquotes
« Reply #1 on: October 01, 2008, 11:01:01 PM »

Code: [Select]
#include "module.h"
#define AUTHOR "n00bie"
#define VERSION "$Id: global_randquotes.c v1.0.1 27-08-2007 n00bie $"

/*
************************************************************************************************
** Module : global_randquotes.c
** Version : 1.0.0
** Author : n00bie (n00bie@rediffmail.com)
** Release : 27th August, 2007
************************************************************************************************
** Description:
**
** Display a random quotes when users connect. The quotes will be displayed by 'Global'
** using notices. Random quotes are read from the file 'quotes.db'. New quotes can be
** added or remove on-the-fly from the quotes database.
************************************************************************************************
** Tested: 1.7.18, 1.7.19
**
** Usage:
** Put the file 'quotes.db' inside services folder (nix) or inside the 'data' folder(windows).
** I've included 325 lines of quotes inside the database, feel free to add more or remove them ^^
**
** Note: Every IRCd(?) have a message limit per line, so remember to keep your quotes line by
** line and try to keep them per the limit. For more info please consult your IRCd documentation.
************************************************************************************************
** This program is free software; you can redistribute it and/or modify it under the
** terms of the GNU General Public License as published by the Free Software
** Foundation; either version 1, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY
** WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS for
** a PARTICULAR PURPOSE. THIS MODULE IS DISTRIBUTED 'AS IS'. NO WARRANTY OF ANY
** KIND IS EXPRESSED OR IMPLIED. YOU USE AT YOUR OWN RISK. THE MODULE AUTHOR WILL
** NOT BE RESPONSIBLE FOR DATA LOSS, DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF
** LOSS WHILE USING OR MISUSING THIS MODULE.
**
** See the GNU General Public License for more details.
************************************************************************************************
** This module have no configurable option.
*/

#define QuotesDB "quotes.db"

int doGlobal(int argc, char **argv);
int AnopeInit(int argc, char **argv)
{
EvtHook *hook;
int status = 0;
hook = createEventHook(EVENT_NEWNICK, doGlobal);
status = moduleAddEventHook(hook);
if (status != MOD_ERR_OK) {
alog("global_randquotes: Something isn't init right.");
return MOD_STOP;
} else {
alog("global_randquotes: Successfully loaded module.");
}
moduleAddAuthor(AUTHOR);
moduleAddVersion(VERSION);
return MOD_CONT;
}

void AnopeFini(void)
{
alog("global_randquotes: Module unloaded.");
}

int doGlobal(int argc, char **argv)
{
User *u = finduser(argv[0]);
int flines;
int rline;
int i;
char buf[2000];
FILE *fp = fopen(QuotesDB, "r");
srand(time(NULL));
if (!(fp)) {
alog("global_randquotes: error opening quotes database file %s. It might not exists!", QuotesDB);
return MOD_CONT;
}
for (flines = 0; fgets(buf, sizeof(buf), fp) ; ++flines);
if (flines == 0) {
alog("global_randquotes: the quotes database file %s is empty!", QuotesDB);
} else {
rline = rand() % (flines + 1);
rewind(fp);
for (i = 0; i < rline; ++i)
fgets(buf, sizeof(buf), fp);
notice_user(s_GlobalNoticer, u, "\2Notícia:\2 %s", buf);
}
fclose(fp);
return MOD_CONT;
}
/* EOF */

any can help me to change notice message "notice_user" for privmsg?
Logged

katsklaw

  • Guest
Re: [Request] global_randquotes
« Reply #2 on: October 02, 2008, 01:23:54 AM »

anope_cmd_privmsg()
Logged

Andrey

  • Anope User
  • Offline Offline
  • Gender: Male
  • Posts: 65
    • RedeNorte
Re: [Request] global_randquotes
« Reply #3 on: October 02, 2008, 07:18:09 AM »

anope_cmd_privmsg()

you can say all line, i tried many form, but dont work, i'm noobie.

Thanks for help
Logged

katsklaw

  • Guest
Re: [Request] global_randquotes
« Reply #4 on: October 02, 2008, 10:54:32 AM »

anope_cmd_privmsg(s_GlobalNoticer, u, "\2Notícia:\2 %s", buf);
Logged

Andrey

  • Anope User
  • Offline Offline
  • Gender: Male
  • Posts: 65
    • RedeNorte
Re: [Request] global_randquotes
« Reply #5 on: October 03, 2008, 01:05:42 AM »

anope_cmd_privmsg(s_GlobalNoticer, u, "\2Notícia:\2 %s", buf);

*** LINK: Sent ERROR to Services.xxx.xxx: Unrecognised or malformed command 'PRIVMSG' -- possibly loaded mismatched modules

dont work

Thanks
Logged

Andrey

  • Anope User
  • Offline Offline
  • Gender: Male
  • Posts: 65
    • RedeNorte
Re: [Request] global_randquotes
« Reply #6 on: October 12, 2008, 11:44:53 PM »

 ???
Logged

Andrey

  • Anope User
  • Offline Offline
  • Gender: Male
  • Posts: 65
    • RedeNorte
Re: [Request] global_randquotes
« Reply #7 on: January 26, 2009, 03:11:45 PM »

 ???
Logged

Jan Milants

  • Team
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 1372
Re: [Request] global_randquotes
« Reply #8 on: January 26, 2009, 05:09:46 PM »

n00bie still maintains that module as far as I know, so you r best off asking the author..
Logged
If you like me donate coins to 1FBmZVT4J8WAUMHKqpWhgNVj3XXnRN1cCk :)

n00bie

  • Anope User
  • Offline Offline
  • Gender: Male
  • Posts: 411
Re: [Request] global_randquotes
« Reply #9 on: January 27, 2009, 12:46:35 PM »

try

notice(s_GlobalNoticer, u->nick, "[Random Quotes] %s", buf);
Logged
I am always doing things that which I cannot do, in order that I may learn how to do it.

Andrey

  • Anope User
  • Offline Offline
  • Gender: Male
  • Posts: 65
    • RedeNorte
Re: [Request] global_randquotes
« Reply #10 on: January 28, 2009, 05:00:54 AM »

try

notice(s_GlobalNoticer, u->nick, "[Random Quotes] %s", buf);

Thanks for reply, i try this, but keep send by notice, dont in pvt.

Ob: This module work in anope 1.8.
Logged

n00bie

  • Anope User
  • Offline Offline
  • Gender: Male
  • Posts: 411
Re: [Request] global_randquotes
« Reply #11 on: January 28, 2009, 09:00:40 AM »

Sorry, my bad eyes  :o

anope_cmd_privmsg(s_GlobalNoticer, u->nick, "[Random Quotes] %s", buf);

if that doesn't work, try

privmsg(s_GlobalNoticer, u->nick, "[Random Quotes] %s", buf);

Edit:
and since i haven't got time yet to test on 1.8.0 i'm not sure whether it works or not. Give it a try and let me know if you encounter any problem. Thanks
« Last Edit: January 28, 2009, 09:03:54 AM by n00bie »
Logged
I am always doing things that which I cannot do, in order that I may learn how to do it.

Andrey

  • Anope User
  • Offline Offline
  • Gender: Male
  • Posts: 65
    • RedeNorte
Re: [Request] global_randquotes
« Reply #12 on: January 28, 2009, 02:36:40 PM »

anope_cmd_privmsg(s_GlobalNoticer, u->nick, "[Random Quotes] %s", buf); its work  ;D

Thanks!
Logged
Pages: [1]   Go Up