一个简单有效的事件处理程序类,基于Python3的回调

eventhandler的Python项目详细描述


事件处理程序

是一个基于python3回调的简单有效的事件处理程序类。在

生成状态:

Build StatusCoverage StatusPypiPython package and publish

Github代码和示例https://github.com/davidvicenteranz/eventhandler

快速启动

安装程序包

$ pip install eventhandler

使用示例

让我们看一个由bot使用事件调用控制的聊天室的简单示例。在

您只需将下一个代码保存到一个文件中,然后运行python3来执行它文件名.py在

^{pr2}$

avobe代码必须生成并输出以下内容:

Chatroom's EventHandler object representation...
<class EventHandler at 0x10da97760: onNewuser:[__on_newuser_join, saludate_new_user], onMessage:[__on_message, read_user_message], verbose=False, tolerate_exceptions=False>


** ChatRoom info ** user sergio has joined the chat ** 1 user/s **

bot says:      Hello sergio, welcome to the chat room.
sergio says:   Hello World!
sergio says:   Hey bot, are there anyone here?
bot says:      Nope sergio. Just you and me.

** ChatRoom info ** user david has joined the chat ** 2 user/s **

bot says:      Hello david, welcome to the chat room.
david says:    Hello everybody!
david says:    Hey bot, are there anyone here?
bot says:      Yes david. there are 1 non bots users in the room, you, and me.
sergio says:   Hi david!

** ChatRoom info ** user kate has joined the chat ** 3 user/s **

bot says:      Hello kate, welcome to the chat room.
kate says:     Hey bot, are there anyone here?
bot says:      Yes kate. there are 2 non bots users in the room, you, and me.

感谢您的收看和欣赏。

David Vicente Ranz编写、测试和包装

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在JUnit5中定义优先级   Web驱动程序将焦点切换到iframe的java困难   java JFileChooser没有文件名文本字段选项   本地化是否可以回退到Java中resourcebundle的宏语言(例如,nynorsk>norsk)   禁用时Java断言的性能拖动   未考虑执行中的java jsonschema2pojo maven插件配置   java微调器。setSelection未调用setOnItemSelectedListener函数   序列化XStream:序列化java的反序列化。sql。时间导致错误   java无法理解为什么“ajpnio8009execXX”线程在AbstractQueuedSynchronizer$ConditionObject上阻塞/等待时间。等候   Java date给我的格式是mm/dd/yyyy,其中jquery datepicker的日期格式是dd/mm/yyyy   jsf如何用javaweb应用程序在客户端重写csv文件   雅加达ee Java邮件Api,无法从outlook客户端读取“.msg附件”   java PreparedStatement性能调优