mang0 0 Newbie Poster

Hello all!

I'm using the phenny IRC bot, and I've got this script, to greet people when they join a channel:

#!/usr/bin/env python
"""
greet.py - Phenny Sahana-Eden Greet Module
(c) 2011 Nolan Lum <nol888@gmail.com>
"""

import os, re
import sqlite3

def setup(self):
    fn = self.nick + '-' + self.config.host + '.greet.db'
    fn = os.path.join(os.path.expanduser('~/.phenny'), fn)

    self.g_conn = sqlite3.connect(fn)
    self.g_conn.execute("""CREATE TABLE IF NOT EXISTS users(
        name VARCHAR(60) PRIMARY KEY)""")

    fn = self.nick + '-' + self.config.host + '.greet.txt'
    fn = os.path.join(os.path.expanduser('~/.phenny'), fn)
    if not os.path.exists(fn):
        try: f = open(fn, 'w')
        except OSError: pass
        else:
            f.write('Welcome to #example, %s!\nptressel')
            f.close()

    try:
        f = open(fn, 'r')
        self.g_greet = f.readline().strip()
        self.g_pingList = []
        line = f.readline()

        while line:
            self.g_pingList.append(line.strip())
            line = f.readline()
    except OSError: pass

def f_join(phenny, input):
    if input.nick == phenny.nick:
        return

    cur = phenny.g_conn.cursor()
    cur.execute("SELECT name FROM users WHERE name = ?", (input.nick,))
    if not cur.fetchone():
        phenny.msg(input.sender, phenny.g_greet % (input.nick))
        if phenny.g_pingList:
            phenny.msg(input.sender, ', '.join(phenny.g_pingList) + ': ping');
        cur.execute("INSERT INTO users VALUES (?)", (input.nick,))
        phenny.g_conn.commit()

f_join.priority = 'low'
f_join.event = 'JOIN'
f_join.rule = r'(.*)'
f_join.thread = False

and I need to change the line 24 - 25 part to do something like this; Instead of having \n and then the nick(s) to be pinged, I would like it to read a list of nicks from another file (list.txt or similar) and then send it. It's kinda hard to describe....for example, at the moment when someone joins the channel, the bot goes:

mang0 joined #example
bobthebot: Welcome to #example, mang0!
bobthebot: ping: ptressel

What I would prefer it to do is this: I want the "ping: ptressel" bit to be optional (is that as easy as putting a # before \nptressel? You take out the # to make it active?) and I want the "Welcome to #example" to be in a /notice. (Again, would that be as easy as changing it to /notice %s Welcome to #example"?) This is a fairly urgent question, so all answers are appreciated! More info can be given if needed :)
-mang0

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.